Skip to content

Instantly share code, notes, and snippets.

@gzoller
gzoller / Poof
Last active August 29, 2015 14:16
Problem creating object from reflected constructor in Scala
package co.blocke.m2
import scala.reflect.runtime.currentMirror
import scala.reflect.runtime.universe._
case class PField( fieldName:String )
case class PCaseClass( name:String, fields:List[PField], ctor:MethodMirror )
// sample case classes
case class Simple(a:String, b:Int, c:Boolean)
root@e427cd230b83:/# cat /var/log/mongodb/mongodb.log
Tue Sep 15 00:01:55 [initandlisten] MongoDB starting : pid=12 port=27017 dbpath=/var/lib/mongodb 64-bit host=e427cd230b83
Tue Sep 15 00:01:55 [initandlisten] db version v2.0.6, pdfile version 4.5
Tue Sep 15 00:01:55 [initandlisten] git version: nogitversion
Tue Sep 15 00:01:55 [initandlisten] build info: Linux z6 3.8-trunk-amd64 #1 SMP Debian 3.8.3-1~experimental.1 x86_64 BOOST_LIB_VERSION=1_49
Tue Sep 15 00:01:55 [initandlisten] options: { command: [ "run" ], config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", unixSocketPrefix: "/var/run/mongodb" }
Tue Sep 15 00:01:55 [initandlisten] Assertion: 13651:Couldn't fsync directory '/var/lib/mongodb': errno:22 Invalid argument
0x5d74b3 0x5ddcd9 0x5dc3a9 0x7cc596 0x8d12c3 0x8d22d8 0x58f02c 0x7f42509b8ead 0x58f8e9
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x23) [0x5d74b3]
/usr/bin/mongod(_ZN5mongo11msgassertedEiPKc+0xb9) [0x5d
@gzoller
gzoller / kinetic.bezier.js
Created April 13, 2012 22:43
Kinetic Plug-Ins
/**
* KineticJS Bezier Extension
* Compatible with KineticJS JavaScript Library v3.8.0
* Author: Greg Zoller
* Date: Apr 12 2012
*/
///////////////////////////////////////////////////////////////////////
// Bezier
///////////////////////////////////////////////////////////////////////
@gzoller
gzoller / gzip test (scala fragment)
Created October 11, 2013 06:00
Spray Gzip Problem
val c = new GzipCompressor
val s = """{"baseServiceURL":"http://www.acme.com","endpoints":{"assetSearchURL":"/search","showsURL":"/shows","mediaContainerDetailURL":"/container","featuredTapeURL":"/tape","assetDetailURL":"/asset","moviesURL":"/movies","recentlyAddedURL":"/recent","topicsURL":"/topics","scheduleURL":"/schedule"},"urls":{"aboutAweURL":"www.foobar.com"},"channelName":"Cool Stuff","networkId":"netId","slotProfile":"slot_1","brag":{"launchesUntilPrompt":10,"daysUntilPrompt":5,"launchesUntilReminder":5,"daysUntilReminder":2},"feedbackEmailAddress":"feedback@acme.com","feedbackEmailSubject":"Commends from User","splashSponsor":[],"adProvider":{"adProviderProfile":"","adProviderProfileAndroid":"","adProviderNetworkID":0,"adProviderSiteSectionNetworkID":0,"adProviderVideoAssetNetworkID":0,"adProviderSiteSectionCustomID":{},"adProviderServerURL":"","adProviderLiveVideoAssetID":""},"update":[{"forPlatform":"ios","store":{"iTunes":"www.something.com"},"minVer":"1.2.3","notificationVer":"1.2.5"},{
//---------------------------- build.gradle (Project: gcm)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
@gzoller
gzoller / LateProducer.scala
Last active April 16, 2016 18:48
Kafka populate topic
package com.cof.kafka
import scala.collection.JavaConversions._
import org.apache.kafka.clients.producer.{ ProducerRecord, KafkaProducer, Callback, RecordMetadata }
import kafka.admin.AdminUtils
import kafka.utils.ZkUtils
case class LateProducer() {
def populate(num: Int, host: String, topic: String) {
@gzoller
gzoller / KafkaThread.scala
Last active April 16, 2016 18:57
Kafka 0.9.0.1 Consumer
package com.cof.kafka
import org.apache.kafka.common.serialization.{ ByteArrayDeserializer, Deserializer, StringDeserializer }
import java.util.concurrent.LinkedBlockingQueue
import org.apache.kafka.common.TopicPartition
import org.apache.kafka.clients.consumer.{ ConsumerRebalanceListener, OffsetCommitCallback, ConsumerRecord, KafkaConsumer, OffsetAndMetadata }
import scala.concurrent.Promise
import java.util.concurrent.TimeUnit
import scala.collection.JavaConversions._
import scala.concurrent.Await
case class SpeedGraphRC(system: ActorSystem, host: String, groupId: String, topic: String) extends GraphHolder[String] {
val count = new LinkedBlockingQueue[Int]()
val flow = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: GraphDSL.Builder[akka.NotUsed] =>
import GraphDSL.Implicits._
type In = CommittableMessage[Array[Byte], String]
val consumerSettings = ConsumerSettings(system, new ByteArrayDeserializer, new StringDeserializer)
.withBootstrapServers(host)
@gzoller
gzoller / FlexiFlowExample.scala
Last active November 5, 2018 13:40
Akka Stream FlexiFlow switch example
object PrimaryFlow extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val sj = ScalaJack()
val graph = FlowGraph.closed() { implicit builder: FlowGraph.Builder[Unit] =>
import FlowGraph.Implicits._
val in = Source(List.empty[String]) // hook this up to RabbitMQ
val out = Sink.foreach( (mc:Command) => println("Command:" +mc) )
package co.blocke.reflect
import scala.tasty.file._
import scala.tasty.Reflection
object Main extends App {
val p = Person("Fred", 53)
ReflectClass.showInfo(p)