Skip to content

Instantly share code, notes, and snippets.

@FiloSottile
FiloSottile / gist:2667279
Created May 12, 2012 15:54
Render only an element with PhantomJS
page.clipRect = page.evaluate(function() {
return document.getElementById(ELEMENT_ID).getBoundingClientRect();
});
@FiloSottile
FiloSottile / gist:2352407
Created April 10, 2012 16:02
Get element by id from HTML document using only HTMLParser
import HTMLParser
class IDParser(HTMLParser.HTMLParser):
"""Modified HTMLParser that isolates a tag with the specified id"""
def __init__(self, id):
self.id = id
self.result = None
self.started = False
self.depth = {}
self.html = None
@FiloSottile
FiloSottile / rasterize.js
Created May 12, 2012 15:38
PhantomJS rasterize.js with "Retina" output
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 2 || phantom.args.length > 3) {
console.log('Usage: rasterize.js URL filename');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1280, height: 1024 };
@joyrexus
joyrexus / demo.txt
Last active October 19, 2018 22:25
Demonstrate how to extract and run code blocks from *.lang.md* files.
% marko.coffee -x try.python.md > try.py
% python try.py
hello world!
yes!
% marko.coffee -x try.python.md | python -s
hello world!
yes!
@FiloSottile
FiloSottile / .ArmoryRPi.md
Created September 5, 2012 22:12
Building the Armory Bitcoin client for the Raspberry Pi

Armory on the RPi

Building the Armory Bitcoin client for the Raspberry Pi

This is how I got Armory (etotheipi/BitcoinArmory; http://bitcoinarmory.com/) cross-compiled for the Raspberry Pi.

This is a great way to keep an air-gapped offline wallet for only $30 dollars for the RPi (that you can also use for other things; experiment, it's awesome) and $7 for a Class 10 4GB SD card, really easy to keep in a safe and secret place.

Dependencies

@hdevalence
hdevalence / gist:aac098857248a1c3134eb8101b692547
Created October 30, 2016 17:13
convert sage integers to little endian byte strings
# v--- endianness issues here
bytestr_to_arr = lambda s:"[" + ", ".join(['0x'+b+a for a,b in zip(s[0::2], s[1::2])]) + "]"
ZZtobytestr = lambda x: "".join(ZZ(x).digits(16, '0123456789abcdef'))
@Drakulix
Drakulix / mingw-w64-3.10-osx10.9.sh
Last active January 9, 2020 11:49
Script to install a Mingw-w64 Cross-Compiler Suite on Mac OS X 10.9
#!/bin/sh
# dependencies
echo "Installing dependencies via Homebrew (http://brew.sh)"
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew update
brew install gcc48
@mimoo
mimoo / curve25519.sage
Created November 16, 2017 13:21
Curve25519 with sage
# create curve
ec = EllipticCurve(GF(2**255-19), [0,486662,0,1,0])
base_point = ec.lift_x(9)
point_at_infinity = ec(0)
# all elements of order 4
G4s = ec.lift_x(1, True)
G4 = ec.lift_x(1) # just the first element
# the element of order 2
@bdarnell
bdarnell / fdserver.py
Created July 9, 2011 20:41
Demonstration of sharing file descriptors across processes
#!/usr/bin/env python
"""This is a demonstration of sharing file descriptors across processes.
It uses Tornado (need a recent post-2.0 version from github) and the
multiprocessing module (from python 2.6+). To run it, start one copy
of fdserver.py and one or more copies of testserver.py (in different
terminals, or backgrounded, etc). Fetch http://localhost:8000 and
you'll see the requests getting answered by different processes (it's
normal for several requests to go to the same process under light
load, but under heavier load it tends to even out).
@pcardune
pcardune / .gitignore
Created September 5, 2011 04:55
Facebook command-line client helper
.fb_access_token
.fbconsole.py