Skip to content

Instantly share code, notes, and snippets.

View jjl's full-sized avatar

jjl

View GitHub Profile
@jjl
jjl / prereqs.js
Last active August 29, 2015 14:14
HTML5 prereq checking with Modernizr
function prereqs() {
switch (undefined) {
// Just add another empty case to the list for each thing you require
case Modernizr.getusermedia:
case Modernizr.flexbox:
return false;
break;
default:
return true;
}
@jjl
jjl / gist:11356518
Created April 27, 2014 21:51
OrientDB shines.
WARNING: Committing the active transaction to Committing the active transaction to create the new type 'NpmUser' as subclass of 'V'. The transaction will be reopen right after that. To avoid this behavior create the classes outside the transaction. To avoid this behavior do it outside the transaction
diff --git a/bin/console.sh b/bin/console.sh
index a7f9f67..8868058 100755
--- a/bin/console.sh
+++ b/bin/console.sh
@@ -3,27 +3,9 @@
# Copyright (c) 1999-2010 Luca Garulli
#
-#set current working directory
-cd `dirname $0`
@jjl
jjl / json_array_elements_text.sql
Created January 31, 2014 19:07
The missing useful postgresql json function
CREATE OR REPLACE FUNCTION json_array_elements_text(arr json) RETURNS SETOF text AS $$
BEGIN
RETURN QUERY SELECT arr->>i
FROM generate_series(0,json_array_length(arr)-1) i;
END
$$ LANGUAGE plpgsql;
@jjl
jjl / psql pset options
Last active January 4, 2016 20:49
Options for psql \pset. I've probably forgotten 'expanded' again.
=================== =========== ==================================
Explanation Keyword Value
=================== =========== ==================================
Field alignment format unaligned, aligned, html, or latex
Field separator fieldsep separator
One field per line expanded
Rows only tuples_only
Row separator recordsep separator
Table title title title
Table border border 0, 1, or 2
@jjl
jjl / stacklang.hs
Created January 27, 2014 22:59
"If you show me some code, I'll stop whining"
import Data.List
import Data.Char (isDigit)
import Text.ParserCombinators.Parsec
-- The basic datatype of the language
data Datum = DInt Integer
| DString String
| DFloat Double
| DBool Bool
| DList [Datum] deriving (Eq)
@jjl
jjl / server.sh
Created January 21, 2014 19:46
Serve the current directory over http
python3 -m http.server
# '.' is now served on port 8000
@jjl
jjl / postgres-jdbc-json.clj
Created December 25, 2013 16:00
How to deal with postgres JSON column types through JDBC
(defn pg-json-to-string [thing]
(.setType thing "java.lang.String") ;; "Pretend you are a string"
(.getValue thing)) ;; Now we can actually get the value
@jjl
jjl / middleware.clj
Created December 4, 2013 10:32
Ring middleware
(defn wrap-http-params [handler]
(fn [request]
(let [query-params (request :query-params)
form-params (request :form-params)]
(let [http-params (merge {} query-params form-params)]
(handler (assoc request :http-params http-params))))))
(defn wrap-keyword-http-params [handler]
(fn [request]
(letfn [(kwify [req kw]
@jjl
jjl / snippets.pp
Created November 19, 2013 16:27
Useful puppet snippets
ppa::repo { 'chris-lea/node.js':
ensure => present,
apt_key => "C7917B12",
} -> Exec["apt-get update"]
ppa::repo { 'cassou/emacs':
ensure => present,
apt_key => "CEC45805",
} -> Exec["apt-get update"]