Skip to content

Instantly share code, notes, and snippets.

@pilate
pilate / Markdown
Created October 8, 2012 23:00
PhantomJS Examples
PhantomJS Examples
==================
<script src="https://gist.github.com/3855613.js"></script>
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();
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);
};
@pilate
pilate / listmq.py
Created November 6, 2012 16:47
Get all queue elements from RabbitMQ with pika
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()
@pilate
pilate / emptyrmq.py
Created November 6, 2012 17:04
Empty existing RabbitMQ Queue
import pika, json
# Clear the RMQ
def callback(ch, method, properties, body):
pass
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='Phantom')
channel.basic_consume(callback, queue='Phantom', no_ack=True)
8/24/11:
[21:23] <Jumpie> hah
[21:23] <Jumpie> obama is insane if he thinks he has a flying chance for reelection
8/29/12
[15:02] <Jumpie> just that...obama wont win
[15:02] <+ReadError> he answered the most important question
[15:02] <Jumpie> romney isnt perfect, but he's the better choice
9/7/12
.
|-- Actor-Mixer Hierarchy
| |-- Character
| | `-- CharacterActions
| | |-- ContextSensitiveActions
| | | |-- Ammo_Supply
| | | | |-- AmmoBox_LidClose
| | | | |-- AmmoBox_LidOpen
| | | | |-- AmmoBox_Lift
| | | | |-- AmmoBox_Place
@pilate
pilate / urltitle.py
Last active December 22, 2015 09:59
from HTMLParser import HTMLParser
import requests
import re
url_regex = "(https?:\/\/[^ ]+)"
class TitleParser(HTMLParser):
istitle = False
[hpc72 ~]# nodetool info
Exception in thread "main" java.lang.AssertionError
at org.apache.cassandra.locator.TokenMetadata.getTokens(TokenMetadata.java:465)
at org.apache.cassandra.service.StorageService.getTokens(StorageService.java:2060)
at org.apache.cassandra.service.StorageService.getTokens(StorageService.java:2049)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
@pilate
pilate / logging.py
Created July 14, 2014 17:56
Custom basicConfig test
def get_logger():
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s] %(message)s"))
logger = logging.getLogger("distribute")
logger.addHandler(handler)
logger.setLevel(10)
return logger
logger = get_logger()