Skip to content

Instantly share code, notes, and snippets.

...and it was good.

Delon Newman delonnewman

...and it was good.
Block or report user

Report or block delonnewman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View oracle_enhanced-1882.rb
# model
class Referral
attributes :ended_at, :datetime
# migration
class CreateReferrals ...
def change
create_table :referrals do |t|
View generic-functions.rb
module X
module Generic
Any = BasicObject
def define_generic_method(name, pattern, &blk)
generic_methods[name] ||= {}
generic_methods[name][pattern] = blk
define_method name do |obj, *args|
# This will cost O^n, but it may not be too much of a cost given that cases tend to be few
fn = generic_methods[name].select { |pat, _| pat === obj }.first
View define.rb
class Var
attr_reader :meta, :namespace, :name
def self.intern(namespace, name, init = nil)
@@vars ||= {}
@@vars[name] = begin
v =, namespace, name)
v.set(init) if init
delonnewman / day1.js
Last active Aug 10, 2018
An Introduction to Abstraction with Functions
View day1.js
function square(x) {
return x * x;
function area(r) {
return Math.PI * square(r);
function add1(x) {
return 1 + x;
View comments.xml
This also works
or this -->
<!-- and this too!
AUTH='OAuth oauth_consumer_key="0MR6AA46EH0FRSCHVIR0PH9KKX8",oauth_nonce="sMhmFlY",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1521044097729",oauth_version="1.0a",oauth_signature="f3z97KFOYnIRkNHzQc%2B0Qv%2FQdsI%3D"'
curl -XPOST -H "Content-type: $CONTENT_TYPE" -H "Authorization: $AUTH" --data "[]" "$API_URI/$ENDPOINT"
View .vimrc
" General
set nocompatible
filetype on
filetype plugin on
filetype indent plugin on
set ofu=syntaxcomplete#Complete
set modeline
set history=1000
set clipboard+=unnamed
set ffs=unix,dos,mac
delonnewman / run.php
Created Apr 29, 2017 — forked from greut/run.php
A web server in pure PHP (non-concurrent and concurrent)
View run.php
#!/usr/bin/env php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<meta charset=utf-8>
<title>Hello World!</title>
View escape_mb_chars.php
function escape_mb_chars($str) {
$first = preg_replace_callback('/\p{C}/u', function ($m) {
$char = current($m);
return substr(json_encode($char), 1, -1);
}, $str);
return rtrim($first, '\n');
delonnewman / diff.clj
Created Aug 9, 2016
Joseph McCarthy's diff function in WonderScript
View diff.clj
; vim: set ft=clojure
; Joseph McCarthy's diff function
; see:
; J. McCarthy, Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I, April 1960
; diff [y; x] = [atom[y] →
; [eq[y; x] → ONE; T → ZERO];
; eq[car [Y]; PLUS] → cons [PLUS; maplist[cdr[y]; λ[[z]; diff[car [z]; x]]]];
; eq[car [y]; TIMES] → cons[PLUS; maplist[cdr[y];
; λ[[z]; cons [TIMES; maplist[cdr [y];
You can’t perform that action at this time.