Skip to content

Instantly share code, notes, and snippets.

View DeaconDesperado's full-sized avatar

Mark Grey DeaconDesperado

  • Spotify
  • NY, New York
View GitHub Profile
@DeaconDesperado
DeaconDesperado / AccumulatingFieldsShuttle.java
Last active November 11, 2021 18:33
Attempting calcite field extraction
package com.test.parsersandbox;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.calcite.runtime.CalciteContextException;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlIdentifier;
import org.apache.calcite.sql.SqlNode;
@DeaconDesperado
DeaconDesperado / change.js
Last active May 14, 2020 17:41
MakeChange
//For a given dollar amount (as an integer 100 == $1) compute all combinations of coins
//that can make even change
let changePermutations = (v, coinDenominations) => {
let subCombinations = (accum, sumAccum, total, coins) => {
//Base case: there's no coins left to try or remaining coins would take us beyond zero
if(coins.length == 0 || total < 0) return accum;
//This coin being attempted reduces to zero, making even change
if(total == 0) return accum.concat([sumAccum]);
@DeaconDesperado
DeaconDesperado / example.scala
Created May 10, 2016 01:14
A little less cake
object Main extends App {
val system = ActorSystem("my-system")
val ec = system.dispatcher
//we don't use the actor system ec here, but let's ignore that
val userService = new UserServiceImpl(ec)
val foobarService = new FoobarServiceImpl(userService)
val restActor = system.actorOf(Props(new RestActor(userService, foobarService)) "actor")
}
class RestActor(val userService:UserService, val foobarServiceFoobarService) extends Registry with UserRoutes {
@DeaconDesperado
DeaconDesperado / example.scala
Last active May 10, 2016 01:10
Too much cake!
trait Registry {
val ec:ExecutionContext
val userService = new UserServiceImpl(ec)
val fooBarService = new FoobarServiceImpl(userService)
}
class RestActor extends Registry with UserRoutes {
def receive = {
userRoutes ~
otherRoutesFromOtherMixins
@DeaconDesperado
DeaconDesperado / FormFlow.jsx
Last active August 29, 2015 14:15
React FormFlow
'use strict';
var React = require('react');
var ProgressTracker = require('./js/ProgressTracker.jsx')
var FormFlow = React.createClass({
getInitialState: function(){
return {
statusClass: "pure-u-1-1 status-bar",
controlClass: "pure-u-1-1 control-bar",
nextBtnClass: "button-success pure-button next",
@DeaconDesperado
DeaconDesperado / Makefile
Last active August 29, 2015 14:01
Rsync recipie
watch:
watchmedo shell-command --recursive --command='rsync -avt --delete --exclude '*.pyc' --exclude '.git' . user@remotehost:folder/path'
@DeaconDesperado
DeaconDesperado / models.scala
Last active August 29, 2015 14:01
Reactive Mongo Serializer issue
package com.gn.gncore.models
import java.util.UUID
import org.joda.time.DateTime
import org.joda.time.LocalTime
/** Core place model throughout service
*/
case class Place(
id:String,
package com.spotify.wakka
import akka.actor.{Actor, ActorSystem, Props, ActorLogging, ActorRef}
import akka.routing._
import akka.actor.ActorDSL._
import akka.io.IO
import spray.can.Http
import spray.routing._
import spray.httpx.Json4sJacksonSupport
import org.json4s._
@DeaconDesperado
DeaconDesperado / conf.d
Last active August 29, 2015 13:56
Dead simple nginx reverse proxy
upstream backend {
server 127.0.0.1:8888;
}
server {
listen 80 default;
access_log /var/log/nginx/backend_access.log;
error_log /var/log/nginx/backend_error.log;
location / {