JavaScript OR when assigning value to variable 
<script type="text/javascript">

x=false || 'test';
alert(x);//outputs 'test';

</script>



[ view entry ] ( 1451 views )   |  print article
Amazon Wishlists 
If you found something helpful in this site and want to return the favor,

http://www.amazon.com/gp/registry/wishl ... av_lists_1

but if you really love me...

http://www.amazon.com/registry/wishlist ... _go_o_T1-2

;)



[ view entry ] ( 1857 views )   |  print article
GET & POST in PHP and ASP.NET 
PHP
$_GET
$_POST

ASP.NET
Request.QueryString
Request.Form





[ view entry ] ( 1388 views )   |  print article
Regular Expressions Notes 
. matches any one character
[] character class, matches one character; gr[ae]y matches gray or grey
[^] matches any character not listed.

[1-6] is the same as [123456], which matches any number from 1 to six
[^0-9a-fA-F] is the same as [^0123456abcdefABCDEF], wich matches any character NOT hexadecimal

^ matches start of line
$ matches end of line
\b marches word boundaries

| logic OR, matches either expression it separates, second|2nd matches second or 2nd
() expression grouping, gr(a|e)y matches gray or grey

? matches one optional, Angela? matches Angel and Angela
* matches any amount OK, a*
+ matches at least one, a+

{0,1} the same as ?, a{0,1} the a is optional
{0,10} minimum zero, maximum ten; a{0,10}
{5,8} minumum five, maximum eight.



// Greedy quantifiers
String match = find("A.*c", "AbcAbc"); // AbcAbc
match = find("A.+", "AbcAbc"); // AbcAbc

// Nongreedy quantifiers
match = find("A.*?c", "AbcAbc"); // Abc
match = find("A.+?", "AbcAbc"); // Abc

// Look arounds
//positive lookahead: match Cent only if followed by OS
Cent(?=OS)

// negative lookahead: match Cent only if not followed by OS
Cent(?!OS)

// postive lookbehind: match OS only if preceded by Cent
(?<=Cent)OS

// negative lookbehind: match OS only if not preceded by Cent
(?<!Cent)OS


----------------------------------------------------------------------------------
See:
http://www.pcre.org/pcre.txt
http://www.php.net/manual/en/intro.pcre.php

[ view entry ] ( 1694 views )   |  print article
CCNA Review Notes (exam 640-802) 
Click on related link to view notes.

Topics:
VLAN & Trunking
STP
ACLs
RIP
EIGRP
OSPF
WAN
VPN
IPv6

[ view entry ] ( 1444 views )   |  print article  |  related link
NAT Flavors 
Cisco IOS (routers):
-Static NAT
-Dynamic NAT
-NAT Overload= PAT
-Static PAT= Port Forwarding
-NVI (NAT Virtual Interface), removes inside & outside terminology.

--------------------------------------------
Cisco ASA/PIX firewalls:
-Static NAT
-Policy NAT
-Identity NAT
-NAT Exemption
-Dynamic NAT
-PAT
-Satic PAT

[ view entry ] ( 1293 views )   |  print article
Miscellaneous Linux/Apps/Cisco Commands 
-------------------------------------CISCO--------------------------------------------------
//Clear ACL counters:
router#clear access-list counters

//
Router#show run | include frame-relay map



-------------------------------------APPs Version--------------------------------------------------
//mysql:
mysql> select version();
$mysql -V

//Linux kernel
$uname -a

//CentOS
cat /etc/redhat-release

//Postfix
postconf | grep mail_version

//Dovecot
dovecot --version

-------------------------------------POSTFIX 2.7.2------------------------------------------

//Show queue
#postqueue -p

//empty queue
#postsuper -d all

//Check for MySQL support in Postfix
#postconf -m

//Check for SASL support
#postconf -a

//Postfix configuration file: main.cf

-------------------------------------MySQL--------------------------------------------------

//New user
CREATE USER 'developer'@'localhost' IDENTIFIED BY 'letmein';

//Grant permissions.
GRANT ALL ON DEVELOPMENT_database.* to 'developer'@'localhost';

//Table definition
SHOW CREATE TABLE table_name;
-------------------------------------LINUX--------------------------------------------------

//Searching a string in a folder:
grep -r "string_to_find" /home/mydocuments
//OR use PCRE:
pcregrep -r "string_to_find" /home/mydocuments

//To search for a file in a folder use find:
find /home/mydocuments -name index.php

//Remove directory and its contents
$rm -rf directoryname

//Symbolic link
$ ln -s /webserver/programs/bin/httpd httpd

//Set a file's owner:
$ chown username somefile

//Set a directory's owner:
$ chown username somedirectory

//In order to set the ownership of a directory and all the files in that directory, you'll need the -R option (recursive):
$ chown -R username somedir

//You can also set the file's group at the same time.
//If the user name is followed by a colon and a group name, the file's group will be changed as well.
$ chown username:groupname somefile

//adding a user in CentOS
useradd "username" -g"group"

//adding a group in CentOS
groupadd "groupname"

//change a user password
passwd "username"

//viewing users in CentOS
cat /etc/passwd

//viewing groups in CentOS
cat /etc/groups

//deleting a user in CentOS
userdel "username"

//deleting a group in CentOS
groupdel "groupname"


//change a file's group
chgrp "newgroupname" "file"

//Conditional permissions recursively (only files),a combination of FIND and CHMOD.
//Finding files with 777 permisions and changing them 755:
find /webserver/webroot -type f -perm 777 -exec chmod 755 {} \;

//Finding direct children (files) of a directory with 777 permissions
find /webserver-maxdepth 1 -perm 777

//Finding files with specific permissions
find /webserver/webroot -perm 777

//Setting permissions with CHMOD by number (Also see: Filesystem ACLs)
chmod 755 index.php

0 = --- = no access
1 = --x = execute
2 = -w- = write
3 = -wx = write and execute
4 = r-- = read
5 = r-x = read and execute
6 = rw- = read and write
7 = rwx = read write execute (full access)

...So,

Triplet for u: rwx => 4 + 2 + 1 = 7
Triplet for g: r-x => 4 + 0 + 1 = 5
Tripler for o: r-x => 4 + 0 + 1 = 5

//Compress a directory:
$ tar -zcvf webroot-1-jan-20013.tar.gz /webserver/webroot

//Decompress a directory (extract):
$ tar -zxvf webroot-1-jan-20013.tar.gz /webserver/webroot -C /newserver

//To copy a file from hostB to hostA, while logged in to hostB:
[user@server ~]$ scp -P port filename username[at]hostA.com:.
//(copies file to user's home dir on hostA machine, because of the period after the colon)

//To copy a folder from hostB to hostA, while logged in to hostB first cd to
//the directory on HostB which contains the folder you want to copy:
[user@server ~]$ scp -r -P port folder username[at]hostA.com:.
//(creates new folder if the folder does not exist, again in user's home directory)

//To copy a file from hostA to hostB, while logged in to hostB:
[user@server ~]$ scp -P port username[at]hostA.com:filename .
//(copies into current directory on hostB)

[user@server ~]$ scp -r -P port username[at]hostA.com:folder .
//(copies whole folder into current directory on hostB)

//To copy a file or folder within a folder from hostA to hostB, while logged in to hostB:

[user@server ~]$ scp -P port username[at]hostA.com:/folder/dir/filename .
//(copies into current directory on hostB)

[user@server ~]$ scp -r -P port username[at]hostA.com:/folder/dir .
//(copies whole folder into current directory on hostB)

//Instead of using the '.' to designate files to be copied to a home directory or
// the current working directory you can give scp an actual path (assuming you have write permissions):
[user@server ~]$ scp -r -P port folder username@hostA:/home/httpd/
[user@server ~]$ scp -P port username[at]hostA.com:/folder/dir/filename /home/tmp/

//Searches all files for $_SERVER['SERVER_NAME'] and replaces it with SiteMode()
//Combination of find and sed
find /webserver/html/ -type f -exec sed -i "s/\$_SERVER\['SERVER_NAME'\]/SiteMode()/g" {} \;

//Displaying routing table in CentOS
route -n
netstat -rn
ip route list

//linux command to find the size of a directory
du -sh directory/

//hard disk used/available space
df -h

[ view entry ] ( 1732 views )   |  print article

<<First <Back | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |


2024 By Angel Cool