Skip to content

Instantly share code, notes, and snippets.

@markandey
markandey / Info.py
Created November 21, 2010 12:50
python script which displays a command suggestion to move your images in directories based on their EXIF data (date)
#!/usr/bin/env python
from PIL import Image
from PIL.ExifTags import TAGS
import sys
import datetime
from sys import exit
def get_exif(fn):
ret = {}
i = Image.open(fn)
@markandey
markandey / yqlscraptest.html
Created November 21, 2010 13:00
Example code to get data from wikipedia page using YQL
<HTML>
<HEAD>
<TITLE>YQL DEMO</TITLE>
<script type="text/javascript">
function renderYQL(o) {
var div = document.getElementById("main");
var html = "";
if (div) {
if (o.results[0]) {
count = o.results.length;
@markandey
markandey / Qompress.cs
Created January 4, 2011 10:53
Simple Compress and Decompress in C#.net
using System.IO;
using System.IO.Compression;
class Qompress
{
public static byte[] CompressBuffer(byte[] byteArray)
{
MemoryStream strm = new MemoryStream();
@markandey
markandey / DomJavaScript.html
Created January 28, 2011 23:47
A quick & simple test to show you which browser is faster
<!DOCTYPE HTML>
<html>
<head>
<title>DOM + JavaScript Test</title>
</head>
<script>
var count=0;
var stop=true;
function testfun(){
document.getElementById("count").innerHTML=""+Math.sqrt(count);
@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"}
]
@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 / 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 / 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 / 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 / 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