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
@momania
momania / gist:858476
Created March 7, 2011 13:05
Akka AMQP Loadbalance
import akka.amqp.AMQP._
import akka.amqp._
import akka.actor._
import java.util.concurrent.{TimeUnit, CountDownLatch}
import util.Random
object LoadBalancingDemo {
def main(args: Array[String]) {
@senko
senko / onchange.sh
Last active July 14, 2023 07:54
OnChange - Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@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 ...")
@wting
wting / dreamhost_python_setup.sh
Created May 31, 2012 00:16
Dreamhost Python Setup script
#!/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.3"
setuptools_version="2.7"
tmp_dir="${HOME}/tmp-${RANDOM}"
if [[ ${#} == 0 ]]; then
@akhenakh
akhenakh / tools.py
Created June 19, 2012 14:47
flask jsonify with support for MongoDB from tools import jsonify
try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
raise ImportError
import datetime
from bson.objectid import ObjectId
from werkzeug import Response
@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)
@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)
@chadmaughan
chadmaughan / pre-commit.sh
Last active November 25, 2022 00:38
A git pre commit hook that runs the test task with the gradle wrapper
#!/bin/sh
# this hook is in SCM so that it can be shared
# to install it, create a symbolic link in the projects .git/hooks folder
#
# i.e. - from the .git/hooks directory, run
# $ ln -s ../../git-hooks/pre-commit.sh pre-commit
#
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git commit --no-verify'
@arisetyo
arisetyo / index.html
Created July 12, 2013 16:37
Dynamic Real-time Chart Using Chart.js, Socket.io, and Knockout.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Galenic">
<script src="js/jquery-1.9.1.js"></script>
<script src="js/knockout-2.1.0.js"></script>
<script src="js/Chart.js"></script>
<link rel="stylesheet" href="pure-min.css">