Skip to content

Instantly share code, notes, and snippets.

@nitinhayaran
nitinhayaran / 0_reuse_code.js
Created June 4, 2014 11:48
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
@nitinhayaran
nitinhayaran / .gitignore
Created May 22, 2014 12:15
General Purpose gitignore
# Numerous always-ignore extensions
*.pyc
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
@nitinhayaran
nitinhayaran / gist:5870106
Created June 26, 2013 18:36
create a input text box, similar to an existing div. Copying its text styles.
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop === 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
@nitinhayaran
nitinhayaran / osx.sh
Last active March 7, 2020 05:19
OSX configurations
echo "Expanding the save panel by default"
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
echo "Why is this not default anymore?! Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
echo "I'm in yer computer, hax0ring yr passwords!"
echo "Requiring password immediately after sleep or screen saver begins"
defaults write com.apple.screensaver askForPassword -int 1
@nitinhayaran
nitinhayaran / Gruntfile.js
Created May 18, 2013 07:38
Sample Gruntfile.js
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
@nitinhayaran
nitinhayaran / hack.sh
Created March 31, 2012 14:54 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@nitinhayaran
nitinhayaran / dump_for_mysql.py
Created December 24, 2011 11:02
Quick easy way to migrate SQLite3 to MySQL
#!/usr/bin/env python
"""
sqlite3 sample.db .dump | python dump_for_mysql.py > dump.sql
cat sqllite.sql | python dump_for_mysql.py > dump.sql
"""
import re
import fileinput
def this_line_is_useless(line):
@nitinhayaran
nitinhayaran / studious_student.py
Created January 12, 2011 16:24
Solution for Studious Student Problem in Facebook Hacker Cup 2011 Qualification Round
import sys
def func(stings):
strings.sort(compare)
return ''.join(strings)
def compare(x,y):
if(x.find(y) == 0 or y.find(x) == 0):
return cmp(x+y,y+x)
return cmp(x,y)
@nitinhayaran
nitinhayaran / peg_game.py
Created January 12, 2011 16:00
Solution for Double Square Problem in Facebook Hacker Cup 2011 Qualification Round
import sys
def find_prob(row, col, x, exempt):
size = (row,col)
arr = []
broken = exempt
for i in range(size[0]):
k = []
for j in range(size[1]*2-1):
if(i%2==0):
@nitinhayaran
nitinhayaran / double_square.py
Created January 12, 2011 15:29
Solution for Double Square Problem in Facebook Hacker Cup Qualification Round
import sys
from math import sqrt
def main(filename):
inputf = open(filename,'rU')
totalLines = inputf.readlines()
totalLines.pop(0)
for i in totalLines:
count = 0