This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; | |
$target_url = $argv[1] ; | |
if( !$target_url ) { | |
echo PHP_EOL."You'll have to provide a full url".PHP_EOL; | |
exit(1); | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package ClusteredSessionHandler | |
* | |
* This class replaces the default php session handler with one that is more | |
* suitable for clustered environment. | |
* | |
* It utilizes the database to save the session data and may also use memcache | |
* as a write-throu cache layer to speed up fetching of data | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Timer { | |
protected static $start_time = 0.00; | |
protected static $total_time = 0.00; | |
public static function start() { | |
self::$start_time = microtime(true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SiteTreeOptimizationDecorator extends DataObjectDecorator { | |
public function extraStatics() { | |
return array( | |
'indexes' => array( | |
// Will help when fetching menu's | |
'showinmenus_sort' => '(ShowInMenus,Sort)', | |
// Will help when fetching a page from sitetree | |
'urlsegment_sort' => '(URLSegment,Sort)', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My ./config directory in silverstripe looks like this: | |
# ./503.php <- a 503 Maintainance page | |
# ./_ss_environment.php <- the production environment settings | |
# ./deploy.rb <- is the recipe below | |
# | |
# Application settings | |
set :application, "domain.com" | |
set :shared_children, %w(assets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Installation: curl -o /usr/bin/diskspace.sh "https://gist.githubusercontent.com/stojg/867224/raw" && chmod +x /usr/bin/diskspace.sh | |
du -xsk ./* | sort -n | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t",int(x*10)/10,pref[y],$0); } { for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n"; } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SSH_SERVER=server.com | |
SSH_USER=user | |
REMOTE_DB_USER=remotedbuser | |
REMOTE_DB_PASSWORD=remotedbpassword | |
REMOTE_DB_SCHEMA=remotedbschema | |
LOCAL_DB_USER=localdbuser | |
LOCAL_DB_PASSWORD=localdbpassword | |
LOCAL_DB_SCHEMA=localdbschema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
SAMBAUSERNAME="stig" | |
SERVERNAME="172.16.155.x" | |
PASSWORD="sambapassword" | |
MOUNTPATH="/Volumes/$SAMBAUSERNAME" | |
VMFUSION="/Library/Application Support/VMware Fusion/vmrun" | |
VMPATH="/Users/stig/Documents/CentOS/CentOS.vmx" | |
EDITOR="/Applications/NetBeans/NetBeans 7.0.app" | |
start_vm() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bash/bin | |
php -r 'function gp($a=false){$b=shell_exec("stty -g");if($a===false){shell_exec("stty -echo");$c=rtrim(fgets(STDIN),"\n");}else{shell_exec("stty -icanon -echo min 1 time 0");$c="";while(true){$d=fgetc(STDIN);if($d==="\n"){break;}else if(ord($d)===127){if(strlen($c)>0){fwrite(STDOUT,"\x08 \x08");$c=substr($c,0,-1);}}else{fwrite(STDOUT,"*");$c.=$d;}}}shell_exec("stty ".$b);return $c;}echo"Your gmail @: ";$ha=fopen("php://stdin","r");$f=trim(fgets($ha));echo"Your gmail pass: ";$p=gp(1);echo"\nWhat do you want(enters sends message): ";$m=trim(fgets($ha));function s($c,$m){fputs($c,$m."\r\n");}function r($c){return fgets($c,4096);}function e($m){return base64_encode($m);}function m($f,$p,$m){$r="[email protected]";$n="\r\n";$c=fsockopen("smtp.gmail.com",587,$z,$y,10);r($c);s($c,"HELO");r($c);s($c,"STARTTLS");r($c);stream_socket_enable_crypto($c,true,STREAM_CRYPTO_METHOD_TLS_CLIENT);s($c,"HELO");r($c);s($c,"AUTH LOGIN");r($c);s($c,e($f));r($c);s($c,e($p));r($c);s($c,"MAIL FROM: <$f>");r($c);s($c,"RCPT TO: <$r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ChangeDecorator extends DataObjectDecorator { | |
/** | |
* | |
*/ | |
public function onAfterWrite() { | |
$publisher = PublisherQueueVisitor::instance(); | |
$this->getOwner()->accept($publisher); |
OlderNewer