Skip to content

Instantly share code, notes, and snippets.

@iambibhas
iambibhas / tweetdeck_tco_bypass.js
Created December 10, 2013 16:31
Inject this snippet to bypass t.co urls on Tweetdeck https://tweetdeck.twitter.com/
// ==UserScript==
// @name Tweetdeck T.co bypass
// @namespace http://userscripts.org/users/192333
// @version 1
// @include http*://*twitter.com/*
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_info
// ==/UserScript==
@iambibhas
iambibhas / feed.json
Created December 11, 2013 09:20
Facebook Graph API post format
{
"id": "106976563522_10152113375228523",
"from": {
"category": "Media/news/publishing",
"name": "The Next Web",
"id": "106976563522"
},
"message": "Bored of Instagram? Check out Molome, where photos have stickers. http://tnw.co/1kygbfx",
"picture": "https://fbcdn-photos-d-a.akamaihd.net/hphotos-ak-prn2/1508006_10152113374233523_1837944042_s.png",
"link": "https://www.facebook.com/photo.php?fbid=10152113374233523&set=a.297026458522.179219.106976563522&type=1&relevant_count=1",
@iambibhas
iambibhas / tie_mumbai.json
Created December 11, 2013 10:54
TiE Mumbai Graph API response
{
"id": "321611004898",
"feed": {
"data": [
{
"id": "321611004898_10152481350444899",
"from": {
"category": "Non-profit organization",
"name": "TiE Mumbai",
"id": "321611004898"
@iambibhas
iambibhas / startup-brightness.conf
Created February 20, 2014 20:09
set initial brightness for linux - /etc/init/startup-brightness.conf
start on startup
script
echo "978" > /sys/class/backlight/intel_backlight/brightness
end script
#!/usr/bin/ruby
#
# I recommend using Pocket to do the export. It works better than the browser extensions.
require 'rubygems'
require 'htmlentities'
require 'csv'
# CHANGE THIS
input_file = '/path/to/passwords.csv'
@iambibhas
iambibhas / kolkata-zoom-14.py
Last active May 20, 2023 13:24
Downloads the OSM tiles and stiches them in a single image
#!/usr/bin/env python
# Generated by BigMap 2. Permalink: http://bigmap.osmz.ru/bigmap.php?xmin=12200&xmax=12231&ymin=7120&ymax=7143&zoom=14&scale=256&tiles=mapnik
import io, urllib2, datetime, time, re, random
from PIL import Image, ImageDraw
# ^^^^^^ install "python-pillow" package | pip install Pillow | easy_install Pillow
(zoom, xmin, ymin, xmax, ymax) = (14, 12200, 7120, 12231, 7143)
layers = ["http://tile.openstreetmap.org/!z/!x/!y.png"]
attribution = 'Map data (c) OpenStreetMap'
@iambibhas
iambibhas / freeswitch_dependencies.sh
Created June 3, 2014 11:37
Freeswitch dependencies in Ubuntu 12.04
sudo apt-get install autoconf libtool build-essential libjpeg-dev pkg-config sqlite3 libsqlite3-dev libcurl3 curl libcurl4-openssl-dev zlib1g-dev libzrtpcpp-dev libasound2-dev libogg-dev libvorbis-dev libperl-dev libexpat1-dev libssl-dev libtiff4-dev libx11-dev unixodbc-dev libpcre-dev libpcre3-dev libexpat1-dev libssl-dev libtiff4-dev libx11-dev unixodbc-dev speex libspeexdsp-dev libldns-dev libedit-dev
@iambibhas
iambibhas / aggregators.py
Last active August 29, 2015 14:02
Django PostgreSQL CASE WHEN aggregation
from django.db import models
class SQLSumCase(models.sql.aggregates.Aggregate):
is_ordinal = True
sql_function = 'SUM'
sql_template = "%(function)s(CASE WHEN %(when)s THEN %(field)s ELSE 0 END)"
def __init__(self, col, **extra):
if isinstance(extra['when'], basestring):
extra['when'] = "%s" % extra['when']
@iambibhas
iambibhas / geo_on_json.sql
Created June 15, 2014 10:45
Another way of querying geo data from JSON column
explain analyze
SELECT tmp_table.tid,
tmp_table.screen_name,
tmp_table.text
FROM
(SELECT tid,
data->'user'->>'screen_name' AS screen_name,
data->>'text' AS text,
ST_GeomFromText('POINT(' || CAST(data#>>'{geo,coordinates,1}' as varchar) || ' ' || CAST(data#>>'{geo,coordinates,0}' as varchar) || ')', 4326) AS geom
FROM tweet
@iambibhas
iambibhas / next_palindrome.py
Created August 17, 2014 06:47
Find the palindrome larger than given number
import math
def find_next(n):
try:
n = int(n)
except:
return n
if n < 10:
return n