Skip to content

Instantly share code, notes, and snippets.

🦁
...and it was good.

Delon Newman delonnewman

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 define.rb
class Var
attr_reader :meta, :namespace, :name
def self.intern(namespace, name, init = nil)
@@vars ||= {}
@@vars[name] = begin
v = Var.new(nil, namespace, name)
v.set(init) if init
v
end
@delonnewman
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
<!-- HERE IS A COMMENT -->
<!--
This also works
-->
<!--
or this -->
<!-- and this too!
-->
View api-test.sh
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"'
CONTENT_TYPE=application/json
API_URI='https://training.vialivetext.com/api/memberships'
ENDPOINT=hierarchy
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
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
<?php
$app = function($request) {
$body = <<<EOS
<!DOCTYPE html>
<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
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];
View fish-prompt.sh
function _common_section
printf $c1
printf $argv[1]
printf $c0
printf ":"
printf $c2
printf $argv[2]
printf $argv[3]
printf $c0
printf ", "
View dbval.clj
; from https://aan.io/dumping-datomic-schema/
(let [dbval (d/db conn)]
(->> (d/q '[:find ?ident
:in $ ?p
:where
[:db.part/db :db.install/attribute ?attr]
[?attr :db/ident ?ident]]
dbval :db.part/user)
(map (fn [attr] [(d/entity dbval (first attr))]))
(map (fn [attr]
You can’t perform that action at this time.