Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
UNIVERSITY OF KANSAS MEDICAL CENTER
UNIVERSITY OF KANSAS MEDICAL CENTER
KANSAS STATE UNIVERSITY
THE UNIVERSITY OF KANSAS
SPRINT NEXTEL CORPORATION
SPRINT NEXTEL CORPORATION
SPRINT NEXTEL CORPORATION
GARMIN INTERNATIONAL, INC.
SPRINT NEXTEL CORPORATION
THE UNIVERSITY OF KANSAS MEDICAL CENTER
@dvliman
dvliman / gist:ae0d1123348c62ffe99b
Last active August 29, 2015 14:17
interleave data stream
say you have data sources with pagination, where you iterate with page and per_page
http://host/articles?topic=action (page = [0,1,2,...] per_page = 10 | 20 | 30)
http://host/articles?topic=puzzle (page = [0,1,2,...] per_page = 10 | 20 | 30)
http://host/articles?topic=shooter (page = [0,1,2,...] per_page = 10 | 20 | 30)
http://host/articles?topic=rpg (page = [0,1,2,...] per_page = 10 | 20 | 30)
Each article is tagged one and one only for the 'topic'. And then, you
realize that some topics (action, puzzle, shooter, rpg) are actually 'games'
so you define game is a set topics [action, puzzle, shooter, and rpg)
POST / HTTP/1.1
Host: 350f237e.ngrok.com
X-Real-IP: 192.30.252.46
X-Forwarded-Proto: http
Connection: close
Content-Length: 6884
Accept: */*
User-Agent: GitHub-Hookshot/c703d31
X-GitHub-Event: issues
X-GitHub-Delivery: 716bd100-d252-11e4-99b1-4e101b90a3be
@dvliman
dvliman / gist:aafead60c8c564da4168
Created March 24, 2015 19:08
github issue webhook
{
"action": "opened",
"issue": {
"url": "https://api.github.com/repos/dvliman/tt_github/issues/4",
"labels_url": "https://api.github.com/repos/dvliman/tt_github/issues/4/labels{/name}",
"comments_url": "https://api.github.com/repos/dvliman/tt_github/issues/4/comments",
"events_url": "https://api.github.com/repos/dvliman/tt_github/issues/4/events",
"html_url": "https://github.com/dvliman/tt_github/issues/4",
"id": 64075298,
"number": 4,
@dvliman
dvliman / gist:4118928c1cd3ec7df21c
Created March 24, 2015 20:31
github issue with assignee
{
"action": "assigned",
"issue": {
"url": "https://api.github.com/repos/dvliman/tt_github/issues/11",
"labels_url": "https://api.github.com/repos/dvliman/tt_github/issues/11/labels{/name}",
"comments_url": "https://api.github.com/repos/dvliman/tt_github/issues/11/comments",
"events_url": "https://api.github.com/repos/dvliman/tt_github/issues/11/events",
"html_url": "https://github.com/dvliman/tt_github/issues/11",
"id": 64092589,
"number": 11,
@dvliman
dvliman / t.erl
Last active August 29, 2015 14:19 — forked from jadeallenx/t.erl
% Post/Query string parameter validation.
%
% Mark Allen, [email protected]
%
% Specs [{{name, "param_name"}, {required, true}, {type, function}}, ... ]
% Input [{"name", "value}, ...] just you'd get from post or query string parameters
-module(t).
-export([test/0, test1/0, test2/0]).
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: BLUEPROMOCODE.COM
Registrar: GODADDY.COM, LLC
Sponsoring Registrar IANA ID: 146
([email protected])13> try lists:foreach(fun(Y) -> case Y == 3 of true -> throw(return_atom); false -> ok end end, [1,2,3,4,5]) catch Reason -> io:format("got:~p", [Reason]) end.
got:return_atomok
([email protected])14> try lists:foreach(fun( Y ) -> case Y == 3 of true -> throw(bad_atom); false -> ok end end, [1,2,3,4,5]) catch Reason -> io:format("got: ~p", [Reason]) end.
** exception throw: bad_atom
@dvliman
dvliman / slugify.go
Last active August 29, 2015 14:25
slugify for permalink
// utils.go
func slugify(input string) string {
// 1) trim and lower case input string
// 2) for every subsequent whitespace, collapse to just one whitespace
// 3) for every whitespace, replace with '-'; including from previous step 2)
// 4) for every non alphanumeric character, replace with empty space
}
// utils_test.go
@dvliman
dvliman / validation.erl
Created August 3, 2015 19:15
functional approach in validation. erlang.
-module(validation_utils).
-export([validate_until_first_error/2]).
-export([validate_all_errors/2]).
-type validation_args() :: [term()].
-type validation_funs() :: [{function(), atom()}].
-spec validate_until_first_error(validation_args(), validation_funs()) -> ok | {error, atom()}.
% validate_until_first_error/2 applies list of validation_funs() to each element in args