Skip to content

Instantly share code, notes, and snippets.

@abi
abi / d-h.coffee
Created June 10, 2011 12:46
Diffie–Hellman Key Exchange with CoffeeScript DSLs
us ->
p = prime()
g = primitiveRoot p
send p, g
,
them (data) ->
p = data.p
g = data.g
,
both ->
@abi
abi / ssh_config
Created May 15, 2011 11:26
ssh_config no prompts
# Mirrored at https://gist.github.com/973069
# If you update this file, remember to update the gist because most Gambino setup functions `wget` the gist before
# anything else (before it even installs git)
# When SSH into Github, do not prompt the user if they want to add the host keys to the ~/.ssh/known_hosts file
StrictHostKeyChecking no
# Implicity trust keys so don't if the authenticity of a host like github.com can't be established
VerifyHostKeyDNS yes
@abi
abi / apt.conf
Created May 14, 2011 00:25
apt.conf to make sure that apt-get doesn't prompt us for confirmation when installing deps
APT {
Get {
Assume-Yes "true";
Fix-Broken "true";
};
};
@abi
abi / Blue Github Bookmarklet
Created February 14, 2011 06:40
For better contrast.
javascript:var a = document.getElementsByClassName('js-slide-to'); for (var i=0; i<a.length; i++){a[i].setAttribute('style','color:blue');};var a = document.getElementsByClassName('relatize'); for (var i=0; i<a.length; i++){a[i].setAttribute('style','color:blue');};var a = document.getElementsByClassName('message'); for (var i=0; i<a.length; i++){a[i].setAttribute('style','color:blue');};var a = document.getElementsByTagName('td'); for(var i=0;i<a.length;i++){ a[i].setAttribute('style','background:black')};
@abi
abi / gist:729922
Created December 6, 2010 05:33
A simple script that searches Google and copies the first result link to your clipboard. Usage : google "julian assange"
#chmod a+x {this_file} to make executable and add it to $PATH
query=$(echo $1 | sed 's/ /\+/g')
curl -A "Mozilla/2.01" "http://www.google.com/search?source=ig&hl=en&rlz=&q=$query&btnG=Google+Search" 2>/dev/null|
tr '>' '\n' 2>/dev/null|
grep "<h3 class=\"r\"" -A 1|
grep "href="|
sed 's/.*href="//'|
sed 's/".*//'|
head -n 1 |
//I am trying to use Mongoose to put http://acabee.org on MongoDB. Mongoose looks great but I'm getting an error.
mongoose.model('Boo', {
properties: ['first', 'last', 'age']
});
var db = mongoose.connect('mongodb://localhost/db');
var Boo = db.model('Boo');
debug(Boo);
var u = new Boo({first: 'John', last: 'Doe', age: 18}); <- Error on this line because Boo is not a function apparently
u.save(function(){
//Get access token from clicking one of the urls on
//http://developers.facebook.com/docs/api
//and copying the access_token GET param
var http = require('http');
var fb = http.createClient(443, 'graph.facebook.com');
try{
fb.setSecure(); //SSL
var request = fb.request('GET',
/*
Context for this gist in this blogpost: http://blog.abi.sh/2010/debugging-facebook-connect-locally/
Call setFBCookie(response) inside when you login and receive a response object like here:
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
setFBCookie(response);
//Just printing out the name to make sure everything's right.
//Photo1.jpg is in the Resources folder
CGRect frame = CGRectMake(0, 0, 200, 200);
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame];
frame = CGRectMake(0, 0, 500, 500);
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:frame];
[myImageView setImage:[UIImage imageNamed:@"photo1.jpg"]];
[scrollView addSubview:myImageView];
import urllib
import hashlib
from google.appengine.api import urlfetch
API_KEY = "[REPLACE WITH YOUR API KEY]"
# More information on how notify.io notification sending works -
# http://groups.google.com/group/notify-io/web/developers
payload= {'text' : "some text",