Skip to content

Instantly share code, notes, and snippets.

View xwmx's full-sized avatar

William Melody xwmx

View GitHub Profile

Keybase proof

I hereby claim:

  • I am xwmx on github.
  • I am williammelody (https://keybase.io/williammelody) on keybase.
  • I have a public key whose fingerprint is E40E 93A0 B64B 2240 1128 7058 B720 9D44 B320 8C42

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am alphabetum on github.
* I am williammelody (https://keybase.io/williammelody) on keybase.
* I have a public key whose fingerprint is E40E 93A0 B64B 2240 1128 7058 B720 9D44 B320 8C42
To claim this, I am signing this object:
@xwmx
xwmx / gist:7061260
Last active December 25, 2015 23:59
json pl/v8 functions (not currently tested)
CREATE or REPLACE FUNCTION
json_get(data json, prop text) RETURNS JSON as $$
prop = prop.split('.');
for (var i = 0, len = prop.length; i < len - 1; i++) {
data = data[prop[i]];
}
return data[prop[len - 1]];
$$ LANGUAGE plv8 STABLE STRICT;
@xwmx
xwmx / postsql.sql
Created October 18, 2013 21:11 — forked from tobyhede/postsql.sql
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The
# XML Reader is a good way to move a cursor through a (large) XML document fast,
# but is not as cumbersome as writing a full SAX document handler. Read about
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html
#
# Just pass the reader in this parser and specificy the nodes that you are interested
# in in a block. You can just parse every node or only look inside certain nodes.
#
# A small example:
#
; The Lisp defined in McCarthy's 1960 paper, translated into CL.
; Assumes only quote, atom, eq, cons, car, cdr, cond.
; Bug reports to lispcode@paulgraham.com.
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@xwmx
xwmx / _gravatar.html.haml
Last active December 14, 2015 04:29
simple gravatar from email
%a{:href => user_path(@user)}
= image_tag(@user.gravatar_url({:size => 250,
:default => default_gravatar,
:width => "200px",
:height => "200px"}))
Oniguruma Regular Expressions Version 5.9.1 2007/09/05
syntax: ONIG_SYNTAX_RUBY (default)
1. Syntax elements
\ escape (enable or disable meta character meaning)
| alternation
(...) group
@xwmx
xwmx / satipatthana-sutta.markdown
Created November 25, 2012 21:16
Satipatthana Sutta

Majjhima Nikaya 10

Satipatthana Sutta (MN 10)

The Four Paths to Mindfulness

Intermediate Mindfulness Training

Based upon Translations from the Pali by