Skip to content

Instantly share code, notes, and snippets.

Iain Cambridge icambridge

Block or report user

Report or block icambridge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:780986
<?php
$buildFiles = array();
$builds = array();
foreach ( $files as $controller => $controllerFiles ){
foreach ( $controllerFiles as $file ){
if ( !isset($buildFiles[$file]) || !is_array($buildFiles[$file]) ){
$buildFiles[$file] = array();
}
$buildFiles[$file][] = $controller;
View gist:964421
<?php
public static function getTokenObject(){
if ( !is_a(self::$instance,"Wpsqt_Tokens") ){
self::$instance = new Wpsqt_Tokens();
self::$instance->addToken("USER_NAME", "The name of the user who has taken the quiz or survey.")
->addToken("QUIZ_NAME", "The name of the quiz that has been taken, <strong>same as %SURVEY_NAME%</strong>.")
->addToken("SURVEY_NAME", "The name of the survey that has been taken, <strong>same as %QUIZ_NAME%</strong>.")
->addToken("DATE_EU", "The date the quiz or survey was taken in EU format.")
View gist:1020623
#!/usr/bin/env ruby
require 'rubygems'
require 'slop'
options = Slop.parse do
banner "Usage: foo.rb [options]"
on :v, :verbose, 'Enable verbose mode' , :default => false
on :d, :dir, 'The directory to be backed up', true , :optional => false
on :w, :wordpress, 'Is a WordPress site to be backed up' , :default => false
View gist:1193043
threads = []
tracking = ['#potbot','@potbot1','#potbottest','#fml','#cool']
for trackWord in tracking
threads << Thread.new({ :object => TweetStream::Client.new("username", "password"), :word => trackWord }) { |data|
word = data[:word]
stream = data[:object]
View gist:1246674
Iain-Cambridges-MacBook-Pro:~ wackiebackie$ clear
Iain-Cambridges-MacBook-Pro:~ wackiebackie$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
Iain-Cambridges-MacBook-Pro:~ wackiebackie$ gem -v
1.3.7
Iain-Cambridges-MacBook-Pro:~ wackiebackie$ sudo gem install rails
Successfully installed rails-3.1.0
1 gem installed
Installing ri documentation for rails-3.1.0...
@icambridge
icambridge / ArticleControllerTest.php
Created Dec 18, 2011
Controller testing lithium
View ArticleControllerTest.php
<?php
namespace app\tests\cases\controllers;
use app\controllers\ArticlesController;
use app\tests\mocks\MockArticlesController;
class ArticlesControllerTest extends \lithium\test\Unit {
protected $_controller;
View class.webspider.php
<?php
/**
* Web Spider class
*
* @author Iain Cambridge
* @package WebSpider
* @version 0.1
*/
View gist:1636095
<?php
print "Start".PHP_EOL;
$proxyList = file_get_contents('proxylist.txt');
$proxyList = explode(PHP_EOL, $proxyList);
$userAgents = array("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)");
foreach ($proxyList as $proxy) {
list($proxyUrl,$proxyPort) = explode(':',$proxy);
@icambridge
icambridge / gist:1652427
Created Jan 21, 2012
Simple Controller
View gist:1652427
<?php
namespace app\controllers;
class ArticlesController extends \lithium\action\Controller {
protected $_classes = array(
'media' => 'lithium\net\http\Media',
'router' => 'lithium\net\http\Router',
'response' => 'lithium\action\Response'
View gist:1652429
<?php
namespace app\tests\mocks\controllers;
use app\controllers\ArticlesController;
class MockArticlesController extends ArticlesController {
protected $_classes = array(
'media' => 'lithium\net\http\Media',
You can’t perform that action at this time.