Skip to content

Instantly share code, notes, and snippets.

View abh1nav's full-sized avatar

Abhinav Ajgaonkar abh1nav

View GitHub Profile
@abh1nav
abh1nav / Util.java
Created February 1, 2013 07:31
Load AWS credentials from a resource
public class Util {
public static PropertiesCredentials getAwsCredentials() {
PropertiesCredentials creds = null;
try {
creds = new PropertiesCredentials(
Util.class.getResourceAsStream(
"/AwsCredentials.properties"));
}
catch(Exception e) {
@abh1nav
abh1nav / SqsSpout.java
Created February 1, 2013 07:28
A proper SQS spout for Storm
package com.crowdriff.engine.spouts;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;
import backtype.storm.spout.SpoutOutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichSpout;
import backtype.storm.tuple.Fields;
@abh1nav
abh1nav / nexus4.py
Last active December 11, 2015 05:19
Automatically scrape the Play Store to check if the Nexus4 is in stock.
import boto
import requests
urls = { "8GB Nexus4": "https://play.google.com/store/devices/details?id=nexus_4_8gb", "16GB Nexus4": "https://play.google.com/store/devices/details?id=nexus_4_16gb" }
sold_out_text = '<span class="hardware-price-description hardware-large-print hardware-sold-out">Sold out</span>'
headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11" }
for url in urls:
r = requests.get(urls[url], headers=headers)
@abh1nav
abh1nav / Monokai-Refined.vim
Created January 8, 2013 20:16
Monokai Refined VIM theme
" Vim color file
" Converted from Textmate theme Monokai Refined using Coloration v0.3.2 (http://github.com/sickill/coloration)
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
<repositories>
<repository>
<id>twitter4j.org</id>
<name>twitter4j.org Repository</name>
<url>http://twitter4j.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
StatusListener listener = new StatusListener() {
@Override
public void onStatus(Status status) {
// do stuff with tweet
}
@Override
public void onDeletionNotice(StatusDeletionNotice sdn) { }
@Override
public class SampleBolt extends BaseRichBolt {
OutputCollector collector;
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
this.collector = collector;
}
@Override
@abh1nav
abh1nav / .vimrc
Created November 21, 2012 18:48
my vimrc
" Pathogen
call pathogen#infect()
" Font size
set gfn=Menlo:h13
" Line numbers
set nu
" Highlighting
@abh1nav
abh1nav / ISODateParsing.java
Created November 14, 2012 20:18
ISO Date Time String to Joda DateTime
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
public class ISODateParsing {
public static void main(String[] args) {
DateTimeFormatter parser = ISODateTimeFormat.dateTimeNoMillis();
String str = "2012-01-01T00:00:00-0500";
DateTime dt = parser.parseDateTime(str);
@abh1nav
abh1nav / S3.java
Created March 16, 2012 12:39
A storm bolt (S3) that collects tuples from Bolts S1 and S2 and runs only when both tuples have been received.
package com.twitsprout.sproutscore.bolts;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.Maps;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.IRichBolt;