Skip to content

Instantly share code, notes, and snippets.

View parth-patil's full-sized avatar

Parth Patil parth-patil

View GitHub Profile
defmodule LbEcharts do
@moduledoc """
Library to use Echarts in LiveBook
"""
use Kino.JS
asset "main.js" do
"""
export async function init(ctx, chart_data) {
<?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";
}
@parth-patil
parth-patil / RxRedis.scala
Created May 25, 2015 00:51
Exposing some of Redis's streaming operations via Observable
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 / Json4sTest.scala
Last active February 25, 2016 14:10
Json4s Examples
/**
* 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 January 2, 2016 15:08
Detailed log from index task job
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 December 8, 2013 22:36
Exception when running Cassandra Hadoop CQL3 example
➜ 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 April 1, 2012 02:11 — forked from erikh/hack.sh
OSX For Hackers
#!/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
#
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 = {
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 August 29, 2015 14:22
A job queue backed by Redis and has the ability to retry failed jobs
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}