Skip to content

Instantly share code, notes, and snippets.

@urcadox
urcadox / futureBad.scala
Created October 4, 2012 11:58 — forked from dyross/futureBad.scala
Scaling the Klout API with Scala, Akka, and Play
def blockingAndVerbose: Profile = {
val futureName = name()
val futureScore = score()
val futureFriends = friends()
val nameResult = Await.result(futureName, 10 seconds)
val scoreResult = Await.result(futureScore, 10 seconds)
val friendsResult = Await.result(futureFriends, 10 seconds)
Profile(nameResult, scoreResult, friendsResult)
@urcadox
urcadox / alarm.sh
Created April 22, 2013 21:44
Alarm script for PilotSSH
#!/bin/sh
tmux send -t alarm alarm SPACE $1 ENTER
echo "{ \"version\": 1, \"title\": \"Alarm\", \"type\": \"status\", \"status\": \"ok\", \"message\": \"Good night :)\"}"
@urcadox
urcadox / gist:5678556
Created May 30, 2013 15:03
List of countries in the local language
"Afghanestan", "Al Arabiyah as Suudiyah", "Al Bahrayn", "Al Imarat al Arabiyah al Muttahidah", "Al Jaza'ir", "Al Kuwayt", "Al Maghrib", "Al Urdun", "Al Yaman", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Aomen", "Aotearoa", "Argentina", "Aruba", "As-Sudan", "Australia", "Azarbaycan", "Aṣ-Ṣaḥrā’ al-Gharbīyah ", "Bahamas", "Bangladesh", "Barbados", "Belau", "Belgique/Belgie", "Belize", "Benin", "Bermuda", "Bharat", "Bhutan", "Bod ", "Bolivia", "Bosna i Hercegovina", "Botswana", "Brasil", "Bulgaria", "Burkina Faso", "Burundi", "Byelarus", "Cabo Verde", "Cameroon", "Canada", "Cayman Islands", "Ceska Republika", "Chile", "Choson", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comores", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Crna Gora", "Cuba", "Danmark", "Dawlat Qatar", "Deutschland", "Dhivehi Raajje", "Djibouti", "Dominica", "Dominicana, Republica", "Éire", "Ecuador", "Eesti Vabariik", "El Salvador", "Ellas or Ellada", "España", "Estados Unidos M

Keybase proof

I hereby claim:

  • I am urcadox on github.
  • I am urcadox (https://keybase.io/urcadox) on keybase.
  • I have a public key whose fingerprint is E43B 1323 D806 A25A AD59 1A27 07D6 60E5 E621 D21D

To claim this, I am signing this object:

@urcadox
urcadox / Intervals.scala
Last active January 4, 2016 19:49
Get the opposite of a List[Interval] in Scala
import org.joda.time.{Interval, Instant}
val intervals = List(
new Interval(new Instant("2014-01-25T12:00"), new Instant("2014-01-27T08:00")),
new Interval(new Instant("2014-01-27T18:00"), new Instant("2014-01-28T08:00")),
new Interval(new Instant("2014-01-28T18:00"), new Instant("2014-01-29T08:00")),
new Interval(new Instant("2014-01-29T18:00"), new Instant("2014-01-30T08:00")),
new Interval(new Instant("2014-01-30T18:00"), new Instant("2014-01-31T08:00")),
new Interval(new Instant("2014-01-31T18:00"), new Instant("2014-02-01T08:00")),
new Interval(new Instant("2014-02-01T12:00"), new Instant("2014-02-03T08:00")),
@urcadox
urcadox / Filters.scala
Created February 11, 2016 17:23
Play 2.4.6 HTTPS filter
package controllers;
import play.api._
import play.api.http.HttpFilters
import play.api.mvc._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import play.api.Play.current
#!/bin/bash
SLEEP=`echo "$1*3600" | bc`
echo "Alarm triggered in $1 hours"
sleep $SLEEP > /dev/null
echo "Starting playing"
mpc volume 50 > /dev/null
mpc play > /dev/null
mpcfade.sh 50 65 0
mpcfade.sh 65 75 1
echo "Turning on TV and switching input to me"

Keybase proof

I hereby claim:

  • I am urcadox on github.
  • I am urcadox (https://keybase.io/urcadox) on keybase.
  • I have a public key whose fingerprint is 7C92 56D4 AB89 2A42 1D0F FDBF F19E 634D 4F24 A5C7

To claim this, I am signing this object:

alter table records
add constraint cname_single_record_per_name_a
exclude using gist (name with =, "type" with <>)
where ("type" IN ('A', 'CNAME'));
@urcadox
urcadox / repl_2.5.scala
Last active January 22, 2020 11:18
Creating an instance of a class with injected components in Play 2.5.x / 2.6.x / 2.7.x / 2.8.x REPL
// For Play 2.5.x and 2.6.x
// After starting the application in the console (https://www.playframework.com/documentation/2.5.x/PlayConsole#launch-the-interactive-console)
import play.api._
val env = Environment(new java.io.File("."), this.getClass.getClassLoader, Mode.Dev)
val context = ApplicationLoader.createContext(env)
val loader = ApplicationLoader(context)
val app = loader.load(context)
Play.start(app)