Skip to content

Instantly share code, notes, and snippets.

View ashrithr's full-sized avatar
🎯
Focusing

Ashrith Mekala ashrithr

🎯
Focusing
View GitHub Profile
@ashrithr
ashrithr / twitter_stream.rb
Created August 12, 2013 21:44
ruby program to pull data from twitter streaming api
require 'tweetstream'
raise "Requires Argument(s) keyword to match from twitter firehose" if ARGV.length == 0
TweetStream.configure do |config|
# Fill in the details from dev.twitter.com
config.consumer_key = ''
config.consumer_secret = ''
config.oauth_token = ''
config.oauth_token_secret = ''
@ashrithr
ashrithr / kafka_twitter_producer.rb
Last active April 17, 2019 20:00
kafka twitter producer, dumps twitter firehose to kafka.
begin
require 'tweetstream'
require 'poseidon'
rescue 'LoadError'
raise "Requires tweetstream and poseidon libraries"
end
raise "Works only on 1.9" if RUBY_VERSION < "1.9"
raise "Requires Argument keyword to match from twitter firehose" if ARGV.length == 0
@ashrithr
ashrithr / vagrant_centos.rb
Last active July 20, 2016 01:07
Vagrant Files
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = 2
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos/7"
config.vm.hostname = "vagrantbox"
config.vm.network :forwarded_port, host: 80, guest: 8081, auto_correct: true
@ashrithr
ashrithr / DateGenerator.java
Created August 20, 2013 19:03
random data generator java
import org.fluttercode.datafactory.impl.DataFactory;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateGenerator {
public static void main(String[] args) {
DataFactory df = new DataFactory();
Date minDate = df.getDate(2000, 1, 1);
@ashrithr
ashrithr / gist_on_blogger.md
Created August 25, 2013 05:12
Gist on Blogger

At the end of each of your blog posts, include the following code using the HTML editor:

<script src="https://raw.github.com/thedailygoza/gist-Blogger/master/gistBlogger.min.js" type="text/javascript"></script>

Now to include any gist template just add the following anywhere in your blog post (replace GistID with gist id found on url):

<div class="gistLoad" data-id="GistID">Loading ....</div>
@ashrithr
ashrithr / mp.rb
Last active December 21, 2015 16:19
monkey patching
class String
def increment
s = ""
self.each_byte {|b| s << b.next.chr }
return s
end
end
# Usage: "ash".increment
@ashrithr
ashrithr / config.txt
Created August 27, 2013 18:34
Fish prompt with git
function fish_prompt --description 'Write out the prompt'
function _git_branch_name
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
end
function _is_git_dirty
echo (git status -s --ignore-submodules=dirty ^/dev/null)
end
set_color yellow
@ashrithr
ashrithr / .sbtconfig
Created September 2, 2013 18:33
fix sbt startup error (Error during sbt execution: java.lang.OutOfMemoryError: PermGen space) on macosx
echo 'SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:PermSize=256M -XX:MaxPermSize=512M"' > ~/.sbtconfig
@ashrithr
ashrithr / RandomHttpLogGen.scala
Last active September 20, 2023 21:00
Scala script to generate random http log events to a output file specified, one can specify the number of events to generate per second. Also, class IPGenerator can take in number of sessions and session length which can be used to simulate a user returning back.
#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#
import scala.collection.mutable.Map
import scala.util.Random
import scala.collection.mutable.ArrayBuffer
import java.io._
class IPGenerator(var sessionCount: Int, var sessionLength: Int) {
@ashrithr
ashrithr / TwitterStreamExample.java
Created September 4, 2013 07:04
Twitter4j and GeoCode Parsing
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;