Skip to content

Instantly share code, notes, and snippets.

View jpbougie's full-sized avatar
👨‍🌾
Growing some code

Jean-Philippe Bougie jpbougie

👨‍🌾
Growing some code
View GitHub Profile
@jpbougie
jpbougie / challenge.md
Last active December 10, 2015 14:18 — forked from rafbm/challenge.md

CSS Challenge #2

You start with this:

And must end up with this:

@jpbougie
jpbougie / gist:1827065
Created February 14, 2012 14:22
Example of a SOAP request with Finagle
import java.net.InetSocketAddress
import scala.xml.{Elem, XML}
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.util.CharsetUtil.UTF_8
import com.twitter.finagle.Service;
import com.twitter.finagle.builder.ClientBuilder;
import com.twitter.finagle.http.{Http, RequestBuilder};
import org.jboss.netty.handler.codec.http._
import org.jboss.netty.buffer.ChannelBuffers.wrappedBuffer
import java.net.URL
@jpbougie
jpbougie / gist:1005858
Created June 3, 2011 04:09
flatten sets without duplicates
(def f (fn x[i] (if (set? (first i)) (if (not-empty (apply intersection (map x i))) "duplicates!" (apply union (map x i))) i)))
@jpbougie
jpbougie / translate.ll
Created May 5, 2010 23:29
a rough scheme lexer in LLVM IR
; FILE type for i/o using stdio
%struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
%struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 }
@.read_mode = private constant [3 x i8] c"rb\00", align 1
declare i32 @fgetc(%struct.FILE* nocapture) nounwind
declare i32 @feof(%struct.FILE* nocapture) nounwind
import itertools
import math
skew(0.0, 0.0)
stroke(0.3, 0.3, 0.3, 1.0)
class ConcentricCircle(object):
def __init__(self, x, y, radius, qty, attraction, width):
self.x = x
self.y = y
from calendar import HTMLCalendar
from datetime import date
from itertools import groupby
from django.utils.html import conditional_escape as esc
from django.template.loader import get_template
from django.template import Context
class WorkoutCalendar(HTMLCalendar):
diff --git a/src/main/scala/dispatch/Json.scala b/src/main/scala/dispatch/Json.scala
index 776da7b..14ef7e9 100644
--- a/src/main/scala/dispatch/Json.scala
+++ b/src/main/scala/dispatch/Json.scala
@@ -123,7 +123,7 @@ object JsValue {
def toJson(x: JsValue): String = x match {
case JsNull => "null"
case JsBoolean(b) => b.toString
- case JsString(s) => "\"" + s + "\""
+ case JsString(s) => "\"" + s.replaceAll("\\\\", "\\\\\\\\").replaceAll("\\\"", "\\\\\"") + "\""