Skip to content

Instantly share code, notes, and snippets.

Avatar

Bibhas iambibhas

View GitHub Profile
@iambibhas
iambibhas / startup-brightness.conf
Created February 20, 2014 20:09
set initial brightness for linux - /etc/init/startup-brightness.conf
View startup-brightness.conf
start on startup
script
echo "978" > /sys/class/backlight/intel_backlight/brightness
end script
View lastpass_to_keepassx.rb
#!/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 / freeswitch_dependencies.sh
Created June 3, 2014 11:37
Freeswitch dependencies in Ubuntu 12.04
View freeswitch_dependencies.sh
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
View aggregators.py
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
View geo_on_json.sql
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
View next_palindrome.py
import math
def find_next(n):
try:
n = int(n)
except:
return n
if n < 10:
return n
@iambibhas
iambibhas / test.md
Created September 10, 2014 06:20
school comparison
View test.md
         school_name             |               school_name                |     cluster_name      |    cluster_name     |  block_name  |  block_name  |     district
  |     district      

-------------------------------------+------------------------------------------+-----------------------+---------------------+--------------+--------------+------------- ------+------------------- LPUBS EAST EXTENSION | HPUBS NO.5 EXTN RANEBENNUR | RANEBENNUR (URDU) | URBAN URDU | RANEBENNUR | RANEBENNUR | HAVERI
| HAVERI MOORARJI RESI SHALE | MORARJI DESAI RESIDENTIAL SCHOOL | HUNSUR SOUTH | KARIMUDDANA HALLI | HUNSUR | HUNSUR | MYSORE
| MYSORE VES HPS VYALIKAVAL | VAYALIKAVAL EDU SOCIETY HPS VAYALIKAVAL | KADU MALLESHWARA | PALACE GUTTAHALLI | NORTH2 | NORTH2 | BANGALORE U NORTH | BANGALORE U NORTH

@iambibhas
iambibhas / generate_qrcodes.py
Last active August 29, 2015 14:06
I'm using this script to generate QR codes for all the PyCon India 2014 attendees' names and ticket id
View generate_qrcodes.py
import csv
import qrcode
from PIL import Image, ImageFont, ImageDraw
attendees = []
with open('completed_attendees.csv') as userlist:
userreader = csv.reader(userlist, delimiter=',')
for row in userreader:
attendees.append({
@iambibhas
iambibhas / assesment.ipynb
Created December 3, 2014 17:33
Assesment Anomaly
View assesment.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iambibhas
iambibhas / tco_bypass.js
Created January 8, 2015 06:27
Tweetdeck Web t.co bypass
View tco_bypass.js
// ==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==