Skip to content

Instantly share code, notes, and snippets.

@markandey
markandey / json.js
Created December 11, 2012 22:16
json parse and stringify
/*
http://www.JSON.org/json2.js
2010-03-20
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
@markandey
markandey / scrape.js
Created December 11, 2012 21:57
scrape
function getXPath(url) {
if (url.indexOf('http://www.w3schools.com/') >= 0) {
return '//div[@class="example_code notranslate"]';
}
if (url.indexOf('http://www.php.net/') >= 0 || url.indexOf('http://php.net/') >= 0) {
return '//div[@class="phpcode"]';
}
return '//pre';
}
@markandey
markandey / injector.py
Created December 11, 2012 13:41
simple sublime text plugin code
import sublime
import sublime_plugin
class CodeinjectorCommand(sublime_plugin.TextCommand):
def run(self, edit):
sels = self.view.sel()
for sel in sels:
string = self.view.substr(sel)
self.view.replace(edit, sel, "hello "+string);
@markandey
markandey / delhi-radio.html
Created October 31, 2012 21:28
delhi-radio
<html>
<head>
<title>Delhi Radio</title>
<script src="http://yui.yahooapis.com/3.7.3/build/yui/yui-min.js"></script>
<script src="radio.js">
function sing(songResult) {
var marquee = "",
songName = "";
try {
marquee = songResult.results[0] + "";
@markandey
markandey / extract.html
Created April 18, 2012 07:03
Extract names from text
<textarea id="tu" cols="90" rows="10">Your text goes here </textarea>
<input id="btget" class="mybutton" type="button" value="Go Extract Info"/>
<div id="imgdiv" ></div>
<script>
function init(){
var contentanalysisURL="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20contentanalysis.analyze%20where%20text%3D%22{text}%22&format=json&callback=?";
//this function will be called on json recieve
function receiveJSON(data){
//6. recieve Data
@markandey
markandey / parallel_exec.sh
Created March 28, 2012 12:54
Shell Script to Execute commands in parallel
#!/bin/sh
##################################################################################
# R E A D T H I S B E F O R E U S I N G
# This script is to help you in executing a list of thing in parralel. this will fork background processes
# if you want to kill background processes use pkill -9 <yourscripname>
#
# -- U S A G E
# suppose you have 10 thousands items in a file which requires some || processing
# Note: if you are doing pure math, do not make it ||lel will not help much on single core CPU.
# but if you are doing some network operation, u can make it ||lel it will help you for sure!!
@markandey
markandey / colorrainbow.js
Created March 3, 2012 16:04
Generate color rainbow list items
function getColor(noOfColors){
html="";
frequency=5/noOfColors;
for (var i = 0; i < noOfColors; ++i){
var xspan=(i%10)+2;
var yspan=Math.floor(i/10);
yspan=(1-yspan/2);
r = Math.sin(frequency*i + 0) * (127) + 128;
@markandey
markandey / getPictures.js
Created March 3, 2012 16:01
GetPictures from google filter supports based on color
/************************
function getPictures: returns image from query
filter: 0 no filter, 1 for grayscale and subsequent for
color from color index
isFlickr: true if only flickr photos
callback: function to call after load is complets
function(image,results){
image is image object of first image
results are the array of images
}
@markandey
markandey / alchemy.py
Created December 31, 2011 05:45
Python code snippet to wrap AlchemyAPI (on app engine)
###############################################
# DoConceptTagging ############################
###############################################
class DoConceptTagging(webapp.RequestHandler):
def get(self):
q = self.request.get('q', '');
callback= self.request.get('cb', '');
param=urllib.urlencode({
'apikey':'key',
'outputMode':'json',
@markandey
markandey / keyboard.js
Created February 25, 2011 12:00
keyboard shortcuts
[
{ 'j' : "next Item" , 'k': "prev Item" , 'v': "open Item"},
{ 's': "sneak Peek" , 'z': "zoom-In" , 'x': "zoomOut", 'd': "change Color", 'w': "changeFont"},
{ 'n': "decrease width", 'm': "increase width"},
{ 'c': "configuration", 'f':"share on Facebook", 't': "share on twitter"}
]