Sometime we want to use javascript to be used in our ASP.NET (or any server side scripting language). The problem will occur if we want to get/store value from javascript to ASP.NET UI component (example asp:TextBox). Since the rendered ID of the ASP.NET component is generated in the runtime, so it’s difficult to set the ASP.NET component’s ID to the javascript in development process.
I suggest to assign the ASP.NET component’s ID to javascript in the code-behind file. In this article, I will explain how to add javascript pop-up calendar into the ASP.NET page.
In the ASP.NET page:
<asp:TextBox ID="StartDate" runat="server" CssClass="NormalTextBox" ReadOnly="false" Width="80"/>
……
<asp:ImageButton ID="imageButtonStartDate" runat="server" ImageUrl="~/images/calendar.png"/>
The image button will be used as a trigger to show the pop-up calendar. In code-behind, in the Page_Load() method, we need to do:
Registering the javascript into the ASP.NET
String moduleDir = this.TemplateSourceDirectory;
Page.ClientScript.RegisterClientScriptInclude("scw", moduleDir + "/JS/scw.js");
Add the action into the image button, choose OnClientClick
imageButtonStartDate.OnClientClick = "scwShow(" + StartDate.ClientID + ",event); return false;";
The scwShow method need to get the ASP.NET TextBox’s component ID. StartDate is the ID of the ASP.NET TextBox component. Use ClientID to get the ID of the TextBox.
First of all, create a sequence:
CREATE SEQUENCE question_sequence;
Then create the table:
CREATE TABLE question (
ID INTEGER NOT NULL PRIMARY KEY DEFAULT nextval(’question_sequence’),
QUESTION_TEXT CHARACTER VARYING(250),
QUESTION_LEVEL CHARACTER VARYING(50)
);
Description
Rsync is a command in unix/linux terminal that enables us to transfer just the differences between two folders interconected to some networks. The italic word just gives us a clue on how to transfer files efficiently. One application of this usability is for speeding up back-up processes, i.e. no need for transfer a big chunk of folder that we have in both ends but only the differences between them.
How does it work?
We can straightly use it from the linux terminal. Ex: in ubuntu open applications -> accessories –> terminal
Local machine: rsync [OPTION...] SRC... [DEST]
Access via remote shell:
Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
Access via rsync daemon:
Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]
rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
Push: rsync [OPTION...] SRC... [USER@]HOST::DEST
rsync [OPTION...] SRC... rsync://[USER@]HOST[:PORT]/DEST
For Frequent Back-up
For frequent back-up, it will be convenient if we can make a shell command file containing the necessary instructions for back up. With just calling that command, the back-up will be done in few seconds/minutes (depending on the folder size). Here is an example (case study).
Remote server for backup: www.backupdomain.com, folder: $HOME/test, username: user
Local folder: $HOME/Documents/test
We can create the shell command file as follows.
#!/bin/bash
STRING:"Backup is done"
rsync -avz –delete -e ssh ~/Documents/test use@backupdomain.com:~/test
echo $STRING
exit 0
save the above shell command in executable .sh file and just invoke the command whenever it is necessary. We may want to put the command in the cron-job for scheduled backup..
Note that the option –delete means that the backup will delete the file that does not exist at the sender side.
Reference:
[1] http://www.samba.org/ftp/rsync/rsync.html
Syntax
tar -[option] [compressed file]
For reference purposes, the following list is a description of the tar options used to extract compressed file :
x (extract)
tar will extract from the passed filename (as opposed to creating a new file).
v (verbose)
tar will print verbose output as files are extracted. You may omit this flag if you do not wish to see each file as it is unpacked.
z (zipped)
tar will use gunzip to decompress the source. This option assumes that you are using the GNU tools; other versions of tar may not support the z flag. In the event that you are not using the GNU tools, you will need to manually unzip the file using gunzip before you can unpack it with tar.
f (file)
tar will use the filename following the f parameter to determine which file to extract.
In order to check the version of installed MySQL Server, we can use following command
mysql -V
The result in our machine is
mysql version 14.12 Distrib 5.0.26, for pc-linux-gnu (86_64) using readline 5.0
Case: There is a need to use pgAdmin in local machine to connect to the postgresql remotely. One option is use SSH tunneling from local machine to remote machine.
Assumption made:
in remote machine, the postgresql run in port 5432 (default port)
SSH can be use to encrypt the network connection between clients and a PostgreSQL server. First make sure that an SSH server is running properly on the same machine as the PostgreSQL server and that you can log in using ssh as some user.
To create tunnel between our machine and remote machine using SSH, we could use command:
ssh -L [local port]:[localhost]:[remote port] [user]@[remote machine domain]
example:
ssh -L 5454:localhost:5432 user007@some-domain.com
you will be prompted to enter the password of the user007 in the some-domain.com
Open the pgAdmin and add new server. Set host to localhost, port 5454, SSL is not required, set maintained DB to blank.
A text editor is a program used to create and modify the text files. Two principal Unix text editor are vi and emacs. Powerful, mature, full-featured program, by far, the most widely used editors.
Starting vi
To start vi, the basic syntax is:
vi [-rR] [file]
Command mode and input mode
When working with vi, data is kept in a storage called an editing buffer. If we can to edit file using vi, vi copies the contents of the file to the editing buffer. We are not working with the original, we use the copy instead.
Command Mode
Whichever typed keys will be interpreted as commands.
Input Mode
Everything key typed to the editor, will be inserted directly into a buffer.
Inserting Text
There are tweleve commands to change to input mode. Half of these commands are for entering new data; the other half are for replacing existing text.
Here are the commands:
Command
|
Description |
| i |
change to input mode: insert before cursor position |
| a |
change to input mode: insert after curson position |
| I |
change to input mode: insert at start of current line |
| A |
change to input mode; insert at end of the current link |
| o |
change to input mode: open bellow current line |
| O |
change to input mode; open above current line |
Deleting Text
There are several ways to delete data from the editing buffer, using both vi and ex commands. The vi commands are:
| Command |
Description
|
| x |
delete character at cursor |
| X |
delete character to left of cursor |
| D |
delete from cursor to end of line |
| dmove |
delete fro cursor to move |
| dd |
delete the entire current line |
Writting Data to a File
There are several command to write data to a file. The commands are:
| Command |
Description |
| :w |
write data to original file |
| :w file |
write data to a new file
|
| :w! file |
overwrite an existing file |
| :w>> file |
append data to specified file |
Find sometext
/sometext