Skip to content

Instantly share code, notes, and snippets.

@raghothams
raghothams / prototypal-inheritence
Created September 16, 2014 17:46
Javascript inheritence
{
"name": "Inheritence",
"cells": [
{
"in": "// prototypal inheritence\n// http://oli.me.uk/2013/06/01/prototypical-inheritance-done-right/\n",
"out": "3"
},
{

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@raghothams
raghothams / 0_reuse_code.js
Created January 25, 2014 10:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@raghothams
raghothams / py-unicode.py
Created January 21, 2014 18:40
Python Unicode conversion error
# Solving unicode to ascii conversion error
str1 = '\xc6\xe5\t\xc5\xba\xc6;\xe4y\xdf8\xd8U\xcb\xff\xaaT@\r&\x8c\xbd\x95v'
print type(str1)
str_in_ascii = str1.encode('base-64')
print type(str_in_ascii)
@raghothams
raghothams / from-dos.sh
Created January 8, 2014 16:39
Convert Dos to unix eol. Remove ^M
#!/bin/bash
cd ${1}
for f in `find .*rc`; do
echo $f
tr -d '\15\32' < $f > $f.tr
mv $f.tr $f
done
@raghothams
raghothams / flash-image
Created November 15, 2013 05:39
Flash Google factory images
adb reboot bootloader
fastboot flash bootloader bootloader-hammerhead-HHZ11d.img
fastboot reboot-bootloader
fastboot flash radio radio-hammerhead-M8974A-1.0.25.0.17.img
fastboot reboot-bootloader
fastboot -w update image-hammerhead-krt16m.zip
fastboot reboot-bootloader
@raghothams
raghothams / .gitattributes
Created August 23, 2013 09:28
Git eol markers
* text=auto
* text eol=crlf
*.html text eol=crlf
*.css text eol=crlf
*.js text eol=crlf
*.json text eol=crlf
import datetime
import time
# some datetime object
dt = datetime.datetime.now()
# get the seconds since epoch for that datetime
print time.mktime(dt.timetuple())
from flask import request, make_response,
def any_response(data):
ALLOWED = ['http://localhost:8888']
response = make_response(data)
origin = request.headers['Origin']
if origin in ALLOWED:
response.headers['Access-Control-Allow-Origin'] = origin
return response
@raghothams
raghothams / mongobackup.sh
Created July 31, 2013 05:01
shell script to backup DB from mongo
#!/bin/bash
cd ~/backups
folder=$(date +%Y%m%d)
mkdir $folder && cd $folder
mongodump -d sharurl
tar -cvf dump.tar.gz ./dump
rm -rf ./dump