Skip to content

Instantly share code, notes, and snippets.

@oscarrenalias
oscarrenalias / gist:3914875
Created October 18, 2012 21:35
Cheatsheet Play enumerators, enumeratees, iterators and iteratees
// --- cheat sheet ---
//
// Enumerator &> -> filters the output of the enumerator through an Enumeratee
// Enumerator >>> -> alias for andThen; adds the output of the second enumerator after the first one is done
// Enumerator |>> -> feeds the output of the enumerator into the given iteratee for processing
// --- end of cheat sheet ---
// Example
// Iteratee that sums up the size of the input:
@oscarrenalias
oscarrenalias / framework.scala
Created October 5, 2012 20:20
This is small implementation of a tiny MVC-oriented framework inspired by the design * of the Play Framework 2.0; it is meant as an educational exercise to get more familiar with * the concepts of partial functions, function composition and generic type
/**
* This is small implementation of a tiny MVC-oriented framework inspired by the design
* of the Play Framework 2.0; it is meant as an educational exercise to get more familiar with
* the concepts of partial functions, function composition and generic types in Scala
*
* How to run:
* scalac framework.scala
* scala App
*/
@oscarrenalias
oscarrenalias / type-bounds.scala
Created October 4, 2012 18:50 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@oscarrenalias
oscarrenalias / configuration.scala
Created October 2, 2012 21:40
Type-safe configuration in Scala
trait Handler
class Handler1 extends Handler
class Handler2 extends Handler
trait HandlerConfiguration {
val handler1: Handler
val handler2: Handler
}
@oscarrenalias
oscarrenalias / node-event-emitter.js
Created September 10, 2012 18:47
An example of an event emitter class in Node.js
var events = require('events'),
util = require('util');
EventGenerator = function() {
events.EventEmitter.call(this);
this.read = function() {
var data = "this is new data";
this.emit("data", data);
}
@oscarrenalias
oscarrenalias / git-colors.sh
Created August 24, 2012 18:22
Enabling git integration with Bash in OS X
git config --global color.branch auto
git config --global color.diff auto
git config --global color.status auto
var https = require('https');
// https://www.yammer.com/api/v1/messages.json
var options = {
host: 'www.yammer.com',
path: '/api/v1/messages.json?access_token=YOUR-OAUTH2-TOKEN',
headers: { "Authorization": "Bearer YOUR-OAUTH2-TOKEN" }
}
var globalRequestId = 1;
@oscarrenalias
oscarrenalias / version1.bas
Created May 14, 2012 07:38
VBA Macro to change language of all texts to English
Sub LangInFrames()
scount = ActivePresentation.Slides.Count
For j = 1 To scount
fcount = ActivePresentation.Slides(j).Shapes.Count
For k = 1 To fcount
If ActivePresentation.Slides(j).Shapes(k).HasTextFrame Then
ActivePresentation.Slides(j).Shapes(k).TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUK
End If
Next k
Next j
* List of commits not pushed to origin yet:
git log origin/master..master
//
// How to start the embedded H2 web server in a Play Scala application
//
org.h2.tools.Server.startWebServer(play.api.db.DB.getConnection()(play.api.Play.current))
// the browser should automatically open but if not, the correct URL is http://192.168.255.11:58024/
// alternatively, this code only starts the web server (and the connection data must be manually provided). The
// correct port is 8082