Editing Topic
For now, just a replacement for ref.pollestad.net. == PHP Arrays == PHP Arrays are easy but it's the multi-arrays that kicked my ass. Here is how to do a mutli-dimesional array: Two ways of filling it in: * $a[1] = array("1", "2", "3"); * $a[2] = array("3", "2", "1"); or * $try[] = array("11", "12", "15"); * $try[] = array("6", "7", "16"); Essentially the same thing. Now, the thing to remember when printing is that the arrays cannot be in quotes. Example: * print("$a[0][1]") prints out "Array[1]" while * print($a[0][1]) prints out what we want. Use print("blah" . $a[1][1] . "blah") to include in strings. == Sed == To globally replace every occurance of some pattern within any file: * cat wrong.txt | sed 's/wrong pattern/good pattern/g' > good.txt (If you don't use /g, it will only replace the occurrence one per line, but will check every line) You can also do several substitions on the same file: * sed -e 's/Second/Third/' -e 's/Third/Fourth/' wrong.txt > good.txt http://www.suwald.com/linux-gnu/sed-howto.html == awk == Basic awk (prints out a column from a file): * cat file | awk '{print $2}' This will print the second column separated by spaces from file. == Oracle == Connecting via command line to SQLPlus: (be sure that the ORACLE_HOME env variable is set) * ./sqlplus uid/pwd@TNS:DBNAME This Oracle SQL statement will display the names of all the tables within the current user's schema: * SELECT table_name FROM user_tables; To display the names of all the tables that the current user has access to, use: * SELECT table_name FROM all_tables; http://st-curriculum.oracle.com/tutorial/DBXETutorial/index.htm == SQL == - Logical Operators Listing the names and ages of employees whose last names begin with S or P and who are less than 30 years of age. * SELECT f_name, l_name , age from employee_data where (l_name like 'S%' OR l_name like 'A%') AND age < 30; Note the usage of parenthesis in the statement above. The parenthesis are meant to separate the various logical conditions and remove any ambiguity. http://www.webdevelopersnotes.com/tutorials/sql/sql_primer_logical_operators.php3 - Update (Search/Replace) When doing an SQL update that requires a search/replace, the following SQL query should do the trick: * update news set text = replace(text, 'oldtext', 'newtext') where rec=503; Note that you can also use "trim" fuctions if needed: * set text = replace(LTRIM(RTRIM(text)) Sample p.net php code would look like this (after performing a fetch_array while() loop...): * query_db("update news set text = replace(text, '$oldtext', '$newtext') where rec=$rec", 0); http://www.sqlteam.com/article/using-replace-in-an-update-statement == tcsh == Setting environment variables: * setenv EDITOR vi To append: * setenv PATH $PATH\:/usr/sbin Be sure to escape any ":" that you add or you'll get an error. == SSL Certs == First, to generate a cert with no password and is self-signed (so Apache doesn't prompt us) (this assumes you have openssl installed and working...): * ./openssl genrsa -out rpssl.key 1024 * ./openssl req -new -key rpssl.key -out rpssl.csr * ./openssl x509 -in rpssl.csr -out rpssl.crt -req -signkey rpssl.key -days 3650 (cert is valid for 10 years) * ./openssl x509 -in rpssl.crt -text -noout (views the completed cert) To generate a self-signed with password, simply change the first command to read: * ./openssl genrsa -des3 -out rpssl.key 1024 (note the -des3 parameter) The link below also details how to set up your own CA if you want to certify against that. http://www.vanemery.com/Linux/Apache/apache-SSL.html
Add/Upload Screenshots:
Only PNG, JPG and GIF file type are supported.
File exceeded maximum allowed limit of 1000 KB
Attach another file
* If you wish to cancel your edit, simply click the back button on your browser.
Menu
Home
Manage Categories
Categories
Dedicated Servers
Freeswitch
PHP
Recipes
Reference
Speech-To-Text