Skip to content

Instantly share code, notes, and snippets.

View mancvso's full-sized avatar
🏠
Working from home

Alejandro Vidal Castillo mancvso

🏠
Working from home
View GitHub Profile
@timperrett
timperrett / unfiltered-webjars.md
Created April 29, 2015 20:01
Using WebJars with Scala Unfiltered

Add the relevant webjars to your build file:

  libraryDependencies += "org.webjars.bower" % "angular" % "1.3.15"

Add the resources to your server definition:

unfiltered.netty.Server
@vhazrati
vhazrati / PullApplicationActorLess.scala
Created December 21, 2011 11:30
Code changed as per Viktors recommendations
object PullApplicationActorLess extends App {
var context: ZMQ.Context = null
var pullSocket: ZMQ.Socket = null
context = ZMQ.context(5)
pullSocket = context.socket(ZMQ.PULL)
pullSocket.connect("tcp://127.0.0.1:5555")
println("Starting consumer ...")
@edofic
edofic / MongoDb.scala
Created June 10, 2013 21:28
reactive mongo without play
package models
import com.typesafe.config.ConfigFactory
import reactivemongo.api.{DefaultDB, DB, MongoDriver}
import akka.event.slf4j.Logger
import reactivemongo.api.collections.default.BSONCollection
import scala.util.Try
object MongoDb {
private val logger = Logger("MongoDB")
@kevwil
kevwil / Boot.scala
Last active December 18, 2015 15:48
AskTimeoutException
package my.test.app
import akka.actor.{ActorSystem,Props}
import akka.io.IO
import spray.can.Http
object Boot extends App {
implicit val system = ActorSystem("Tester")
val service = system.actorOf(Props[TesterActor], "tester-service")
IO(Http) ! Http.Bind(service, interface = "0.0.0.0", port = 8080)
#!/usr/bin/env bash
# Written by William Ting for the following blog post:
# http://williamting.com/posts/2012/04/18/set-up-python-and-django-on-dreamhost/
rcfile="${HOME}/.bashrc"
version="2.7.5"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then
@doitian
doitian / gitlab-hipchat.coffee
Created December 9, 2013 19:28
Send gitlab notifications through hubot API, customized color and messages comparing to the bult-in hipchat service integration in Gitlab
# Description:
# Post gitlab related events using gitlab hooks and hipchat API
#
# Dependencies:
# "url" : ""
# "querystring" : ""
#
# Configuration:
# HIPCHAT_TOKEN
# GITLAB_ROOT
package database;
import com.esotericsoftware.reflectasm.ConstructorAccess;
import com.esotericsoftware.reflectasm.FieldAccess;
import org.bson.*;
import org.bson.codecs.Codec;
import org.bson.codecs.DecoderContext;
import org.bson.codecs.EncoderContext;
import java.lang.reflect.Array;
@ElectricCoffee
ElectricCoffee / then.scala
Last active May 27, 2016 22:58
Lets you call subroutines sequencially without code blocks, more info in the file
/*
* The premise of this is simple; it allows you to chain subroutines without using a block
* The idea comes from Haskell's Monads, where by language design you can't normally
* predict the order of statement execution due to the language being lazy,
* so instead an operator was added that allowed you to call statements sequencially
*
* Rather than writing something like this:
* def printStuff(): Unit = {
* println("blah")
* println("bloo")
@fancellu
fancellu / MyQuote.scala
Last active June 8, 2016 22:11
Very simple example of Scala "string" Interpolation (more than just strings though)
//http://docs.scala-lang.org/overviews/core/string-interpolation.html
implicit class MyQuote(ctx:StringContext){
def x(args:String*):String=ctx.parts.zip(args).map{case (p,a)=>s"$p$a"}.mkString("")
}
val string="STRINGY"
val string2="STRINGY2"
println(x"Part1 $string Part2 $string2 Part3 $string")
@sam
sam / Helpers.scala
Created March 13, 2013 20:05
ScalaTest Helpers for testing Futures. Scala, Currying, Pattern Matching and Functional Programming is awesome.
def whenReady[A](result:Future[A], timeout:Duration = 1 second)(expectation: A => Unit) = {
expectation(Await.result(result, timeout))
}
def tryWhenReady[A](result:Future[Try[A]], timeout:Duration = 1 second)
(failure:Throwable => Unit)
(expectation: A => Unit) = {
Await.result(result, timeout) match {
case Failure(e) => failure(e)
case Success(result:A) => expectation(result)