Skip to content

Instantly share code, notes, and snippets.

View sajal's full-sized avatar
💭
What's happening?

Sajal Kayan sajal

💭
What's happening?
View GitHub Profile
@sajal
sajal / dns_update.py
Created January 6, 2012 20:16
DYI dynamic DNS using python/boto
from boto.route53.connection import Route53Connection
import urllib2
from syslog import syslog
# ======= CONFIG ========
AWS_ACCESS_KEY_ID = 'XXXXXXXXXXXXXXXXXX'
AWS_SECRET_ACCESS_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
DDNSNAME = "foo.example.com." # Should end in period
ZONEID = "XXXXXXXXX"
# ===== END CONFIG ======
@sajal
sajal / do.py
Created January 8, 2012 15:40
Dont give up
def do_task():
"""
Customise this
"""
this_will_always_fail()
def attempt_task():
try:
do_task()
print "Success at last!"
@sajal
sajal / cloudfrontapi.js
Created January 18, 2012 11:08
Cloudfront API Access from JS (needs cross-domain XHR)
/*
Check : https://github.com/sajal/Cloudfront-Purge-Tool/blob/master/cloudfrontapi.js for maintained version.
Author: Sajal Kayan
URL: http://www.cdnplanet.com/
License: Undecided probably BSD style
Description: Access to CloudFront API from browser. Requires crossdomain XHR!!!.
Wont work from webpages, but i'm making this for chrome extention.
Sample Usage :
@sajal
sajal / date.coffee.js
Created August 13, 2012 18:21 — forked from dandoyon/date.coffee.js
Coffeescript generated javascript for angular-ui ui-date directive
/*
jQuery UI Datepicker plugin wrapper
@param [ui-date] {object} Options to pass to $.fn.datepicker() merged onto ui.config
*/
angular.module('ui.directives').directive('uiDate', [
'ui.config', function(uiConfig) {
var options;
options = {};
@sajal
sajal / s3output.py
Created October 19, 2012 17:31
S3Output for storing disco reduce items directly to Amazon S3
from disco.worker.classic.func import task_output_stream
class S3Output(object):
"""
Output stream for S3.
key from each reduce becomes key name in S3
If gzip param is True, it gzips before uploading.
AWS_KEY, AWS_SECRET and BUCKET_NAME in params is required.
"""
def __init__(self,stream,params):
@sajal
sajal / magiclist.py
Created October 23, 2012 22:02
Memory efficient list...
from collections import defaultdict
import math
class MagicList():
"""
An attempt to make a python object which could potentially hold
unlimited values with finite distinct values.
All items are not stored in memory, only the count of each distinct item is.
So if you want to hold say 1 million numbers where each number is between 1 to 5000,
this should be a better choice than a list.
@sajal
sajal / s3lineoutput.py
Created October 29, 2012 18:40
Output stream for S3
from disco.worker.classic.func import task_output_stream
class S3LineOutput(object):
"""
Output stream for S3.
key from each reduce becomes key name in S3
If gzip param is True, it gzips before uploading.
AWS_KEY, AWS_SECRET and BUCKET_NAME in params is required.
"""
def __init__(self,stream,params,partition, url):
@sajal
sajal / .config
Created February 25, 2015 16:46
gccgo on WT1520
#
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_ppc40x is not set
# CONFIG_TARGET_realview is not set
# CONFIG_TARGET_arm64 is not set
# CONFIG_TARGET_sunxi is not set
@sajal
sajal / ripe_abuf.go
Created March 27, 2015 15:40
Decode RIPE ATLAS DNS results.
package main
import (
"encoding/base64"
"fmt"
"github.com/miekg/dns"
)
func main() {
//Decode base64 to binary
@sajal
sajal / ripe_abuf.js
Created March 27, 2015 15:43
Node.js example for RIPE ATLAS DNS result
var Packet = require('native-dns-packet');
var buf = new Buffer("f2+AgAABAAEAAAAAA3d3dwRyaXBlA25ldAAAAQABwAwAAQABAAA3+gAEwQAGiw==", 'base64');
var p = Packet.parse(buf)
console.log(p)