Skip to content

Instantly share code, notes, and snippets.

View loicdescotte's full-sized avatar

Loïc Descotte loicdescotte

View GitHub Profile
@casualjim
casualjim / ScalatraWebSocket.scala
Created December 18, 2010 21:15
WebSocket support for scalatra
package com.mojolly.websocket
import org.scalatra._
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
import org.eclipse.jetty.websocket.{WebSocket => ServletWebSocket, WebSocketFactory}
import akka.util.Logging
import java.io.UnsupportedEncodingException
import org.eclipse.jetty.websocket.WebSocket.Outbound
import collection.mutable.{ HashSet, SynchronizedSet }
@brikis98
brikis98 / PlayAsyncIOGotchas.java
Created July 6, 2011 01:43
Play framework async I/O gotchas
public class AsyncTest extends Controller
{
public static void gotchas()
{
params.put("foo", "bar"); // Check if changes to params survive the request being suspended
renderArgs.put("foo", "bar"); // Check if changes to renderArgs survive the request being suspended
final String foo = "bar"; // Must be declared final to use in the callback
F.Promise<WS.HttpResponse> remoteCall1 = WS.url("http://www.remote-service.com/data/1").getAsync();
F.Promise<WS.HttpResponse> remoteCall2 = WS.url("http://www.remote-service.com/data/2").getAsync();
@seratch
seratch / build.sbt
Created December 1, 2011 06:07
Scala School - Testing with specs2 examples
organization := "net.seratch"
name := "sandbox"
version := "0.1"
scalaVersion := "2.9.1"
libraryDependencies ++= Seq(
"junit" % "junit" % "4.9" withSources(),

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jto
jto / it.scala
Created April 21, 2012 04:08
humf
package controllers
import play.api._
import play.api.mvc._
import play.api.libs.ws._
import play.api.libs.iteratee._
import play.api.libs.concurrent._
object Application extends Controller {
@sadache
sadache / gist:3026886
Created July 1, 2012 05:01
Bits'bout Play2 Architecture

Bits'bout Play2 Architecture

Play2 Simple HTTP API

Essential blueprint of Play2 architecture is pretty simple and it should be easy to explain in a fairly short blog post. The framework can be understood progressively at different levels; each time having better exposure to some aspects of its design.

The core of Play2 is really small, surrounded by a fair amount of useful APIs, services and structure to make Web Programming tasks easier.

Basically, Play2 is an API that abstractly have the folllowing type

@sadache
sadache / AA.md
Created July 8, 2012 21:29
Is socket.push(bytes) all you need to program Realtime Web apps?

Is socket.push(bytes) all you need to program Realtime Web apps?

One of the goals of Play2 architecture is to provide a programming model for what is called Realtime Web Applications.

Realtime Web Applications

Realtime Web Applications are applications that make use of Websockets, Server Sent Events, Comet or other protocols offering/simulating an open socket between the browser and the server for continuous communication. Basically, these applications let users work with information as it is published - without having to periodically ping the service.

There are quite a few web frameworks that target the development of this type of application: but usually the solution is to simply provide an API that allows developers to push/receive messages from/to an open channel, something like:

@caycefischer
caycefischer / jekyllSyntaxHighlighting.md
Created July 30, 2012 02:19
Various Methods of Syntax Highlighting w/ Jekyll

1. Highlighting the Jekyll way.

This method uses Liquid tags and works when published to Github Pages. It doesn't work in Github's viewer when browsing the repo.

{{ "{% highlight html linenos "}}%}
<div>this is some preformatted code</div>
{{ "{% endhighlight "}}%}

2. Highlighting the Markdown way

@k33g
k33g / 1-dart.md
Created August 23, 2012 08:59
Dart, first steps