This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Brian Kernighan’s Algorithm: | |
/* | |
Subtraction of 1 from a number toggles all the bits (from right to left) till the rightmost set bit(including the righmost set bit). So if we subtract a number by 1 and do bitwise & with itself (n & (n-1)), we unset the righmost set bit. If we do n & (n-1) in a loop and count the no of times loop executes we get the set bit count. | |
Beauty of the this solution is number of times it loops is equal to the number of set bits in a given integer. | |
*/ | |
#include<stdio.h> | |
/* Function to get no of set bits in binary | |
representation of passed binary no. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
from multiprocessing.dummy import Pool as ThreadPool | |
urls = [ | |
'http://www.python.org', | |
'http://www.python.org/about/', | |
'http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html', | |
'http://www.python.org/doc/', | |
'http://www.python.org/download/', | |
'http://www.python.org/getit/', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install python-setuptools zlib1g-dev libbz2-dev libreadline-dev libgdbm-dev libssl-dev libsqlite3-dev curl build-essential libxml2-dev libxslt1-dev libreadline5 libreadline6-dev libxml2 tk-dev libexpat1-dev libncursesw5-dev | |
sudo easy_install pythonbrew | |
pythonbrew_install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# coding: utf-8 | |
import os,socket,threading,time | |
#import traceback | |
allow_delete = False | |
local_ip = socket.gethostbyname(socket.gethostname()) | |
local_port = 8888 | |
currdir=os.path.abspath('.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show git branch | |
function git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return; | |
echo "("${ref#refs/heads/}")"; | |
} | |
PS1="${HOSTNAME}:\w\[\033[1;32m\]\$(git_branch)\[\033[0m\]$"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
// Settings | |
var repeat = localStorage.repeat || 0, | |
shuffle = localStorage.shuffle || 'false', | |
continous = true, | |
autoplay = false, | |
playlist = []; | |
// Load playlist | |
for (var i=0; i<playlist.length; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.gradle; | |
import java.io.PrintWriter; | |
import java.io.ByteArrayOutputStream; | |
import java.io.ByteArrayInputStream; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.BufferedReader; | |
import java.util.zip.GZIPOutputStream; | |
import java.util.zip.GZIPInputStream; | |
import org.apache.commons.collections.list.GrowthList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#./genDb.sh `pwd` | |
#export CSCOPE_EDITOR=`which vim` | |
CSCOPE_FILE=cscope.out | |
if [ -n "$1" ]; then | |
echo "Source code directory: " $1 | |
echo "Create file map : " $CSCOPE_FILE | |
find $1 -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.java" -o -name "*.aidl" -o -name "*.mk" > $CSCOPE_FILE | |
#cscope -bkq -i $CSCOPE_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$(adb shell dumpsys power | grep mScreenOn= | grep -oE '(true|false)')" == false ] ; then | |
echo "Screen is off. Turning on." | |
adb shell input keyevent 26 # wakeup | |
adb shell input keyevent 82 # unlock | |
echo "OK, should be on now." | |
else | |
echo "Screen is already on." | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" In function! eclim#ExecuteEclim | |
.... | |
let g:eclimd_running=1 | |
""" Because the snippet may execute multiple times, I just make the auto-switch between these two plugins execute only one time | |
if !exists('g:mht_enableThePlugin') | |
"""all the eclimrc settings will store in eclimrc.vim, not vimrc for management-easy reason | |
source ~/eclimrc.vim | |
let g:mht_enableThePlugin = 1 |
OlderNewer