Skip to content

Instantly share code, notes, and snippets.

View tamimibrahim's full-sized avatar

Tamim Bin Ibrahim tamimibrahim

View GitHub Profile
@billywhizz
billywhizz / vhost.js
Created April 28, 2011 19:51
Example of vhosts in node.js
var http = require("http");
/*
add following to your hosts config to test:
10.11.12.8 www.vhost1.net
10.11.12.8 www.vhost2.com
10.11.12.8 www.vhost3.test.com
10.11.12.8 static.vhost1.net
@zeroasterisk
zeroasterisk / confirm.sh
Created August 31, 2011 14:04
confirm.sh a simple way to add confirmation to bash scripts
# ======================================================================
#
# @link http://wuhrr.wordpress.com/2010/01/13/adding-confirmation-to-bash/#comment-3540
#
# Function: confirm
# Asks the user to confirm an action, If the user does not answer yes,
# then the script will immediately exit.
#
# Parameters:
# $@ - The confirmation message
@kopiro
kopiro / get-social-counts.php
Created October 29, 2011 11:17
Get social counts from Facebook, Twitter, GPlus
<?php
/* Return object of shared counts */
function get_social_count( $link ) {
$r = (object)array();
$r->facebook = get_social_count_facebook($link);
$r->twitter = get_social_count_twitter($link);
$r->gplus = get_social_count_gplus($link);
return $r;
}
@cjoudrey
cjoudrey / twitter.js
Created November 5, 2011 16:37
Lazy-rendering in PhantomJS
// This example shows how to render pages that perform AJAX calls
// upon page load.
//
// Instead of waiting a fixed amount of time before doing the render,
// we are keeping track of every resource that is loaded.
//
// Once all resources are loaded, we wait a small amount of time
// (resourceWait) in case these resources load other resources.
//
// The page is rendered after a maximum amount of time (maxRenderTime)
@jonathonbyrdziak
jonathonbyrdziak / example.php
Created February 22, 2012 02:27
Wordpress Metabox, stand alone class for multiple metabox abilities
<?php
/*
Here's a couple of metaboxes that I've recently created using this system
*/
$subpostings = redrokk_metabox_class::getInstance('subpostings', array(
'title' => '(optional) Subscription for Postings',
'description' => "As an optional feature, you have a complete api at your disposal which will allow you the ability to offer and manage member posts. In addition to these settings, you may need to create the associated pages for accepting posts from your frontend.",
@julienb74
julienb74 / gist:2157299
Created March 22, 2012 09:23 — forked from firedfox/gist:2037411
check google ads with phantomjs
var page = require('webpage').create();
page.settings.loadImages = false;
page.onConsoleMessage = function(msg) { console.log(msg); };
var pageUrl = 'http://www.bloggersentral.com/2010/08/how-put-add-adsense-on-blogger.html';
var num = 0;
var max = 2;
page.onLoadFinished = function() {
var text = page.evaluate(function() {
@n1k0
n1k0 / sublime-day.js
Created June 28, 2012 09:32
Finds your daily SublimeText2 package using CasperJS. Yeah, randomly.
/**
* Finds your daily SublimeText2 package. Yeah, randomly.
*
* Requires CasperJS: http://casperjs.org/
*
* Usage: $ casperjs sublime-day.js
*/
var casper = require('casper').create();
var f = require("utils").format;
var packages = [];
@thom4parisot
thom4parisot / casper-dump-headers.js
Created July 17, 2012 13:58
Dump Response Headers with CasperJS
var casper = require('casper').create();
casper.start();
casper.open('http://borisschapira.com/');
casper.then(function dumpHeaders(){
this.currentResponse.headers.forEach(function(header){
console.log(header.name +': '+ header.value);
});
});
@iwek
iwek / cookies.js
Created July 17, 2012 14:31
view and disable cookies in casperjs and phantomjs
//to disable cookies, run casperjs --cookies-file=/dev/null? cookies.js
var casper = require('casper').create();
casper.start('http://wordpress.org/', function() {
this.echo('Browser Cookie: ' + this.evaluate(function() {
return document.cookie;
}));
});
@subelsky
subelsky / casperjs_example.js
Created August 8, 2012 18:51
Webscraping with CasperJS, PhantomJS, jQuery, and XPath
var system = require('system');
if (system.args.length < 5) {
console.info("You need to pass in account name, username, password, and path to casperJS as arguments to this code.");
phantom.exit();
}
var account = system.args[1];
var username = system.args[2];
var password = system.args[3];