Skip to content

Instantly share code, notes, and snippets.

Parth Patil parth-patil

Block or report user

Report or block parth-patil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View post_process_balances.php
<?php
while($line = fgets(STDIN)){
$line = trim($line);
list($advertiserid, $ts, $balance_cents) = explode("\t", $line);
$date = date('Y-m-d', $ts);
echo "$date\t$advertiserid\t$ts\t$balance_cents\n";
}
View PageViewGenerator.scala
package com.parthpatil
import java.net.ServerSocket
import java.io.PrintWriter
import util.Random
/** Represents a page view on a website with associated dimension data. */
class PageView(url : String, status : Int, country: String, browser: String, userID : Int)
extends Serializable {
override def toString() : String = {
View FinagleFutureTester.scala
import com.twitter.util.{ Future => TFuture, _}
object Tester extends App {
def test1(): Unit = {
implicit val timer: Timer = new ScheduledThreadPoolTimer()
val startTime = System.currentTimeMillis()
val longProcess: TFuture[String] = TFuture { Thread.sleep(1000); "done" }
longProcess.raiseWithin(Duration.fromMilliseconds(100))
.onSuccess { _ => val elapsed = System.currentTimeMillis() - startTime; println(s"long process Success, elapsed = $elapsed")}
@parth-patil
parth-patil / RedisContidionalQueue.scala
Last active Aug 29, 2015
A job queue backed by Redis and has the ability to retry failed jobs
View RedisContidionalQueue.scala
package com.parthpatil
import com.lambdaworks.redis._
import rx.lang.scala.Observable
import scala.concurrent.{Promise, Future, Await, ExecutionContext}
import scala.concurrent.duration._
import com.google.common.util.concurrent._
import java.util.concurrent.{TimeUnit, ExecutorService, Executors}
@parth-patil
parth-patil / RxRedis.scala
Created May 25, 2015
Exposing some of Redis's streaming operations via Observable
View RxRedis.scala
package com.parthpatil
import com.lambdaworks.redis.output.{KeyStreamingChannel, KeyValueStreamingChannel}
import com.lambdaworks.redis.pubsub.{RedisPubSubConnection, RedisPubSubAdapter, RedisPubSubListener}
import com.lambdaworks.redis.{MapScanCursor, RedisFuture, RedisClient}
import rx.lang.scala.Observable
import scala.concurrent.{Promise, Future, Await, ExecutionContext}
import scala.concurrent.duration._
//import scala.concurrent.ExecutionContext.Implicits.global
import com.google.common.util.concurrent._
@parth-patil
parth-patil / LogTailer.scala
Last active Aug 29, 2015
Future & Observable based APIs for log tailing
View LogTailer.scala
package com.parthpatil
import java.io.File
import java.util.concurrent.LinkedBlockingQueue
import org.apache.commons.io.input._
import rx.lang.scala.Observable
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
@parth-patil
parth-patil / Json4sTest.scala
Last active Feb 25, 2016
Json4s Examples
View Json4sTest.scala
/**
* Make sure you include the following in your build.sbt
"org.json4s" %% "json4s-core" % "3.2.10",
"org.json4s" %% "json4s-jackson" % "3.2.10"
*/
import org.json4s._
import org.json4s.jackson.JsonMethods._
import org.json4s.JsonDSL._
case class Candidate(name:Option[String], age:Option[Int], party:Option[String])
@parth-patil
parth-patil / gist:8321035
Last active Jan 2, 2016
Detailed log from index task job
View gist:8321035
2014-01-08 18:06:17,749 INFO [main] io.druid.server.initialization.PropertiesModule - Loading properties from runtime.properties
2014-01-08 18:06:17,781 INFO [main] org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 5.0.1.Final
2014-01-08 18:06:18,208 INFO [main] io.druid.guice.JsonConfigurator - Loaded class[class io.druid.server.initialization.ExtensionsConfig] from props[druid.extensions.] as [ExtensionsConfig{searchCurrentClassloader=true, coordinates=[], localRepository='/Users/parth/.m2/repository', remoteRepositories=[http://repo1.maven.org/maven2/, https://metamx.artifactoryonline.com/metamx/pub-libs-releases-local]}]
2014-01-08 18:06:18,833 INFO [main] io.druid.guice.JsonConfigurator - Loaded class[class com.metamx.emitter.core.LoggingEmitterConfig] from props[druid.emitter.logging.] as [LoggingEmitterConfig{loggerClass='com.metamx.emitter.core.LoggingEmitter', logLevel='info'}]
2014-01-08 18:06:18,895 INFO [main] io.druid.guice.JsonConfigurator - Loaded class[class io.drui
@parth-patil
parth-patil / gist:7864738
Created Dec 8, 2013
Exception when running Cassandra Hadoop CQL3 example
View gist:7864738
➜ hadoop_cql3_word_count git:(cassandra-2.0) ✗ ./bin/word_count
DEBUG 14:35:30,741 java.io.IOException: config()
at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:227)
at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:214)
at WordCount.main(Unknown Source)
INFO 14:35:30,794 output reducer type: cassandra
DEBUG 14:35:30,801 java.io.IOException: config(config)
at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:260)
at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:341)
@parth-patil
parth-patil / hack.sh
Created Apr 1, 2012 — forked from erikh/hack.sh
OSX For Hackers
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
You can’t perform that action at this time.