Skip to content

Instantly share code, notes, and snippets.

@abi
abi / x
Created February 4, 2009 03:39
/* This is a template command */
CmdUtils.CreateCommand({
name: "hide-lazybar",
homepage: "http://foyrek.com/",
author: { name: "Abimanyu", email: "abimanyuraja@gmail.com"},
license: "GPL",
description: "Hides the LazyBar",
execute: function(input) {
CmdUtils.makeSearchCommand({
name: "alpha",
synonyms: ["wolframalpha"],
url: "http://www.wolframalpha.com/input/?i={QUERY}",
icon: "http://www16.wolframalpha.com/images/favicon.ico",
description: "Searches Wolfram|Alpha. Previews coming as soon as Wolfram|Alpha releases its API."
});
//TODO: force this to be re-evaluated all the time
//if(CmdUtils.getDocument().location.href.indexOf("https://bespin.mozilla.com/") == 0){
var bespin = {cmd : {commands : {}}};
bespin.cmd.commands.add = function(obj){
var cmd = {};
var roles = ["object", "goal", "source", "location", "time"];
var ubiqArgs = [];
@abi
abi / TweetingWithHookpress.py
Created August 4, 2009 14:56
Tweet your new blogposts on Wordpress with Web Hooks/Hookpress
# Python 2.5.2 powered by GAE
#
# Like a typical App Engine environment with req and resp objects.
# Make HTTP requests with: fetch (see App Engine documentation)
#
USERNAME = "username"
PASSWORD = "password"
STATUS = "[infinity symbol goes here] " + req.get("post_title") + " " + req.get("post_url")
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",
//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];
/*
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.
//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',
//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(){
@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 |