Public snipts »
tayhimself's
snipts
showing 1-20 of 52 snipts
-
∞ Freeze project
# To freeze a symfony 1.2 project $ rm web/sf $ symfony project:freeze /usr/share/php/symfony
-
∞ sql insert into syntax
INSERT INTO physiologic_monitoring (subject_id) SELECT id FROM subject id JOIN pm_participants p USING (email) UPDATE participant_summary p JOIN SSSSSS s USING (participant_id) SET p.RDI= s.RDI
-
∞ ie colspan bug
<style type="text/css"> .colspan { width: auto; } </style> .... <td colspan="n" class="colspan">...</td> <!-- or --> <td colspan="n" style="width: auto;">...</td>
-
∞ Nahomail & swiftmailer
#nahomail $ symfony plugin-upgrade nahomailplugin # From http://pear.swiftmailer.org/ $ sudo pear channel-discover pear.swiftmailer.org $ sudo pear remote-list -c swift $ sudo pear install swift/swift-4.0.5
-
∞ windows shares credentials
# delete all shares net use * /delete /yes # get rid of the credentials for a specific share: net use \\YOUR-SHARE-LOCATION /delete /yes #get rid of the credentials for the “Code” share on my NAS: net use \\ETHERNET_BD\Code /delete /yes # to map the share to a drive and give it the credentials YOU want Windows to use, go with: net use DRIVE-LETTER: \\YOUR-SHARE-LOCATION NAS-USER-PASSWORD /user:NAS-USER-NAME # to map the Code share of my NAS to the Z: drive, and access it with a user called bob who has a password MyClevahPass123, I’d use: net use Z: \\ETHERNET_BD\Code MyClevahPass123 /user:bob
-
∞ Outlook junk email avoidance tips
/* Outlook junk email avoidance tips*/ I don't know which criteria it checks against but it is a combination of factors like; -what's in the header -IP-address -computational puzzle -spf DNS-record -size -amount of links -amount of words -amount of embedded objects -certain words -etc... Validity of the addresses in From is not as important. It's more about which address is placed in the To line. If that's not the same as the receiver, in most cases it will be marked as junk.
-
∞ outlook format fixing
/* Adding a tab character to the end of the line also prevents the auto-format */private static String FormatEmailBody(String body) { StringBuilder newText = new StringBuilder(); //two spaces at start of line makes Outlook not remove extra line breaks newText.Append(" "); newText.Append(body.Replace(Environment.NewLine, Environment.NewLine+" ")); return newText.ToString(); }
-
∞ osx force eject
$ drutil tray eject -
∞ Mysql create MD5 hash and limit it to 16 chars
UPDATE director SET login_hash=substr(md5(concat(name_full,email,speciality,personal_id)),1,16)
-
∞ symfony project generation
$ symfony generate:project iom $ php syfony generate:app --escaping-strategy=on --csrf-secret=iomsurvey survey
-
∞ symfony pear installation and upgrade
$ pear channel-discover pear.symfony-project.com # to only upgrade the pear channels and not the symfony channel $ sudo pear update-channels $ sudo pear upgrade pear # to upgrade the symfony channel to the latest 1.2 version # a pear upgrade-all would get symfony 1.4 $ sudo pear upgrade symfony/symfony-1.2.10
-
∞ mysql get most recent item
SELECT STATUS , COUNT( * ) FROM (SELECT subject_id, max( created_at ) AS date FROM study_status GROUP BY subject_id) AS x INNER JOIN study_status s ON ( s.subject_id = x.subject_id AND s.created_at = x.date ) GROUP BY STATUS
-
∞ mysql show processlist
show processlist; show processlist\G;
-
∞ Create symfony guard user
$ symfony guard:create-user --application=frontend jon SoMePasSwOrD
-
∞ Fix non sleep aware modules
# echo 'SUSPEND_MODULES="$SUSPEND_MODULES edimax-driver-name-here' > /etc/pm/config.d/edimax-fix -
∞ burn cd and dvd's in ubuntu
#make the image $ mkisofs -r -J -o yourbackup.iso /home/path_to/your_files #record the image $ cdrecord -v dev=/dev/cdrw --speed=24 -data dfdsdf-02Nov.iso #make an image from a video dvd cat /dev/scd0 > ./orange_county_fl_video.iso #burn dvd $ growisofs -dvd-compat -speed=12 -Z /dev/dvdrw -joliet-long -R -V "myVolume" <filename> $ growisofs -Z /dev/dvdrw -R -J /some/files #can also use cdrecord to burn dvds $ cdrecord -v dev=/dev/cdrw --speed=24 -data dfdsdf-02Nov.iso
-
∞ php conditional shorthand
//B.//asic True / False Declaration $is_admin = ($user['permissions'] == 'admin' ? true : false); //Conditional Welcome Message echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!'; //Conditional Items Message echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.'; //Conditional Basepath echo '<base href="http'.($PAGE_IS_SECURE ? 's' : '').'://mydomain.com" />'; //Nested PHP Shorthand echo 'Your score is: '.($score > 10 ? ($age > 10 ? 'Average' : 'Exceptional') : ($age > 10 ? 'Horrible' : 'Average') ); //Leap Year Check $is_leap_year = ((($year % 4) == 0) && ((($year % 100) != 0) || (($year %400) == 0)));
-
∞ Dump all tables in a mysql database
#!/bin/sh #This scripts returns commands for dumping all the tables in a database #Then you can zip or cat the txt files all_tables=$(mysqlshow -u root -p8l3nxiam dsm_dev | \ awk '{ if (NR >4 ) print $_}' | \ sed -e 's/[|+-]//g; /^$/d ' | \ xargs ) #echo ${all_tables}; for TABLE in ${all_tables}; do echo mysqlshow -uroot -p8l3nxiam dsm_dev $TABLE % \> $TABLE.txt #$(mysqlshow -uroot -p8l3nxiam dsm_dev $TABLE \%) #echo $TABLE done
-
∞ find and xargs with spaces
$find . -type f -print0 | xargs -0 wc -l -
∞ Sed search replace
#replace 999 with nothing sed 's/999//g' output.csv > output-no999.csv #awk print a particular column awk '{print $1"\t"$2}' file.csv



PHP and MySQL Web Development