Skip to content

Instantly share code, notes, and snippets.

View rick4470's full-sized avatar

Rick rick4470

View GitHub Profile
@rick4470
rick4470 / daemon
Last active August 29, 2015 14:14
Create a daemon user on linux
adduser --system --home /location/of/program/to/run --no-create-home username
<?php
/* Detects some common web bots */
function detectBot($USER_AGENT) {
$crawlers_agents = strtolower('Bloglines subscriber|Dumbot|Sosoimagespider|QihooBot|FAST-WebCrawler|Superdownloads Spiderman|LinkWalker|msnbot|ASPSeek|WebAlta Crawler|Lycos|FeedFetcher-Google|Yahoo|YoudaoBot|AdsBot-Google|Googlebot|Scooter|Gigabot|Charlotte|eStyle|AcioRobot|GeonaBot|msnbot-media|Baidu|CocoCrawler|Google|Charlotte t|Yahoo! Slurp China|Sogou web spider|YodaoBot|MSRBOT|AbachoBOT|Sogou head spider|AltaVista|IDBot|Sosospider|Yahoo! Slurp|Java VM|DotBot|LiteFinder|Yeti|Rambler|Scrubby|Baiduspider|accoona');
$crawlers = explode("|", $crawlers_agents);
if(is_array($crawlers)) {
foreach($crawlers as $crawler) {
if (strpos(strtolower($USER_AGENT), trim($crawler)) !== false) {
return true;
}
@rick4470
rick4470 / Pretty Apache
Created February 11, 2015 21:14
Parsing out apache log files
awk '/000.\.000\.000\.000/ {print $5 " " $2 " " $8}' < log.file | less
@rick4470
rick4470 / Daemon
Last active August 29, 2015 14:16
On boot up with a new daemon
sudo update-rc.d Daemon defaults
@rick4470
rick4470 / wgetGrab
Created March 12, 2015 05:31
Grab entire site using wget
wget --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://site/path/
@rick4470
rick4470 / drupal_drush_enable
Created April 1, 2015 04:18
Drupal 7 Enable and Dissable Modules for development
drush dre
@rick4470
rick4470 / ingore_git
Created April 11, 2015 16:05
Ignore changes to a file git
git reset HEAD index.php
git checkout -- index.php
git diff HEAD index.php
@rick4470
rick4470 / lock
Created May 29, 2015 21:34
Locking a mac with the command line
`alias lock=' /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend'`
@rick4470
rick4470 / iphone
Last active August 29, 2015 14:22
Create alias for iphone on terminal
`alias iphone="open -a \"iPhone Simulator\""`
or
`alias iphone="open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app"`
@rick4470
rick4470 / android
Created May 29, 2015 21:35
Android alias
`alias android='/Applications/Android\ Studio.app/sdk/tools/emulator -avd NHMU -netspeed full -netdelay none &'`