Skip to content

Instantly share code, notes, and snippets.

@abishekk92
abishekk92 / fibo.rb
Created May 18, 2012 07:12
Fibonacci
a,b=0,1
sum=0
until a >= 4000000
a,b=b,a+b
if a <= 4000000 && a.even?
sum+=a
end
end
print sum
@abishekk92
abishekk92 / permutation.rb
Created May 18, 2012 13:38
Solution to InterviewStreet Manipulative Numbers
print "Please enter the limits"
number_limit=gets
limit=number_limit.to_i
numbers=[]
xor=[]
def compute_k(foo)
count=0
foo=foo+1 if foo%2==0
until foo ==1
if foo%2==0
@abishekk92
abishekk92 / string.rb
Created May 19, 2012 18:27
Solution to InterviewStreet String Finding
# To change this template, choose Tools | Templates
# and open the template in the editor.
input_limit=gets
limit=input_limit.to_i
inputs=[]
result=0
def compute_result(string1,sub_string)
answer=0
@abishekk92
abishekk92 / foo.html
Created June 12, 2012 11:13
Freemont
<section class="taglineWrap">
<div class="container">
<div class="row-fluid tagline">
<div class="span8"><h2>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, donec odio. Quisque volutpat mattis eros.</h2></div>
<div class="span4 action">
<div>
<a href="#" class="btn first btn-success">Learn More</a>
<span>or</span>
<a href="#" class="btn btn-info">Contact Us</a>
@abishekk92
abishekk92 / MEH
Created August 17, 2012 23:44
In an attempt to teach myself compilers/language design principles,I am starting to write an esoteric programming language,'MEH',with all the swear words in English.I need your help in naming the keywords,please add all the swear words that you know which
Variable definition:
Looping Constructs:
Conditional Statements:
@abishekk92
abishekk92 / gist:3384061
Created August 18, 2012 02:54 — forked from dpobel/gist:2917522
editable region
{if edit_mode()}
<span class="ez-start-editable-region" data-ez-truc="foo"></span>
{/if}
{$attribute.content|wash()}
{if edit_mode()}
<span class="ez-end-editable-region"></span>
{/if}
@abishekk92
abishekk92 / rakefile_devlog.rb
Created September 28, 2012 23:25
Devlog for Octopress. Add the gist in your Rakefile to have octopress generate devlogs from your github activity. You can set up a cron job to do this automatically.
# usage rake devlog
desc "Creates devlog #{source_dir}/#{posts_dir}"
task :devlog do |t|
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
mkdir_p "#{source_dir}/#{posts_dir}"
title = "Devlog #{Date.today-7} to #{Date.today}"
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end
@abishekk92
abishekk92 / slides.slim
Last active December 11, 2015 09:08 — forked from vagmi/slides.slim
section
h All you need to know about consuming APIs
br
br
p Abishek Bhat
p Devloper,Plivo
h2= ENV.inspect
section
h HTTP Verbs
@abishekk92
abishekk92 / type.py
Last active December 12, 2015 02:08
Dynamic type casting
def cast(item):
try:
return int(item)
except:
pass
try:
return float(item)
except:
return item
_cast=map(cast,_list)
@abishekk92
abishekk92 / get_key_for_upc.pig
Created February 12, 2013 09:10
Pig Script for keys with empty UPC/MPN
SET job.name ' General Data dump for $out, Job date: $date';
SET default_parallel 4;
REGISTER 'lib/datalight-0.5.jar'; -- register jar
DEFINE attrib com.indix.datalight.pig.udf.AttributeParserUdf(); -- define shortname
raw = LOAD 'webpage' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('f:bas a:a d:*','-caching 100 -loadKey true -gte $startKey -lte $endKey') as (key:chararray, baseUrl:chararray, attributes:chararray, parsedData:map[]);
data = FOREACH raw GENERATE key,baseUrl, attrib(attributes, parsedData) as productModel:map[];
rows_without_mpn = FILTER data BY (productModel#'upc'==NULL) AND (productModel#'mpn'==NULL);
final= FOREACH rows_without_mpn GENERATE key,baseUrl;
STORE final INTO 'pigdata/datadumps/general/$out/$date.gz/' USING PigStorage('\t');