Skip to content

Instantly share code, notes, and snippets.

@developmentalmadness
developmentalmadness / AkkaHttpWebServer
Created April 29, 2016 18:18
Play WS POST with Iteratee to Akka HTTP Server
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpEntity
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
class TestWebServer(testSystem: ActorSystem){
implicit val system = testSystem
implicit val materialize = ActorMaterializer()
@developmentalmadness
developmentalmadness / HttpClient.scala
Created February 23, 2016 22:27
Make an http GET request with Akka Http
package com.dvMENTALmadness
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
@developmentalmadness
developmentalmadness / RunQuery.scala
Created February 23, 2016 19:55
Query postgresql database using Slick streaming
package com.dvMENTALmadness
import akka.actor.ActorSystem
import slick.driver.PostgresDriver.api._
import scala.collection.immutable.Stream._
import scala.concurrent.duration._
import scala.concurrent.{Future, Await}
import akka.stream._
import akka.stream.scaladsl._
@developmentalmadness
developmentalmadness / DbTableMonitor.scala
Last active February 25, 2016 00:48
How to continuously monitor a postgresql database table for new records (with optional 1/second throttling)
package com.dvMENTALmadness
import akka.actor.ActorSystem
import slick.driver.PostgresDriver.api._
import scala.concurrent.duration._
import scala.concurrent.Await
import akka.stream._
import akka.stream.scaladsl._
import scala.concurrent.ExecutionContext.Implicits.global
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.ComponentModel;
using System.Threading;
namespace DevelopmentalMadness.Utility
{
/// <summary>
@developmentalmadness
developmentalmadness / Program.cs
Last active August 29, 2015 14:04
NEventStore for idempotency prototype thrown together in about 2-3 hours (NEventStore and Unity are the only dependencies)
using CommonDomain;
using CommonDomain.Core;
using Microsoft.Practices.Unity;
using NEventStore;
using NEventStore.Dispatcher;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
@developmentalmadness
developmentalmadness / gist:6024923
Created July 17, 2013 21:57
Sample to create HDInsight mapper - currently results in AggregateException (HttpRequestException)
using Microsoft.Hadoop.MapReduce;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RestaurantUserMapper
{
class Program
@developmentalmadness
developmentalmadness / WalkerAlias.cs
Created May 7, 2013 17:15
Walker Alias implementation converted from java implementation found at http://ramen.physics.und.edu/~yloh/RESOURCES/wamdemo.java
using System;
namespace WeightedSetSelection
{
public class WalkerAlias
{
Random random;
public int N; public double[] ff; public int[] aliasTable;
public WalkerAlias(int N, double[] pp) // pp=probability vector
@developmentalmadness
developmentalmadness / CondensedTable.cs
Created May 7, 2013 17:10
Condensed table (see: http://www.jstatsoft.org/v11/i03) implementation used to provide weighted, random selection of items in a set.
using System;
using System.Collections.Generic;
namespace WeightedSetSelection
{
/// <summary>
/// Creates a table by duplicating entries propotionate to
/// their weight. When samples are requested they will be
/// selected randomly according to weight.
/// </summary>
@developmentalmadness
developmentalmadness / com.tamingtext.classifier.bayes.ExtractTrainingDataTest.txt
Created March 7, 2013 20:59
Tamingtext - build error - failing test com.tamingtext.classifier.bayes.ExtractTrainingDataTest
-------------------------------------------------------------------------------
Test set: com.tamingtext.classifier.bayes.ExtractTrainingDataTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.722 sec <<< FAILURE!
testExtract(com.tamingtext.classifier.bayes.ExtractTrainingDataTest) Time elapsed: 0.41 sec <<< ERROR!
java.io.IOException: Failed to set permissions of path: \tmp\hadoop-MMiller\mapred\staging\MMiller-1897775905\.staging to 0700
at org.apache.hadoop.fs.FileUtil.checkReturnValue(FileUtil.java:680)
at org.apache.hadoop.fs.FileUtil.setPermission(FileUtil.java:653)
at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:483)
at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:318)