Skip to content

Instantly share code, notes, and snippets.

View delonnewman's full-sized avatar

Delon R. Newman delonnewman

View GitHub Profile
@delonnewman
delonnewman / makefile
Created July 1, 2020 18:24
List Makefile targets
# https://diamantidis.github.io/tips/2020/07/01/list-makefile-targets
.DEFAULT_GOAL := help
.PHONY: help
install: ## Install
@echo "Installing..."
run: ## Run
@echo "Running..."
class Record < Hash
def self.has(key_name, opts = {})
opts = { type: opts } if Class === opts
schema[key_name] = opts
end
def self.schema
@schema ||= {}
end

The test is saying that for the input:

42
ibahqaceux
prmv
ovsylj
ta
eovfkgikn
mrhgpexi
(function() {
function atom(val, options) {
var watchers = {};
var validator = options && options.validator || function () { return true; };
function transition(next) {
if (!validator(next)) {
var err = new Error(next + " failed validation");
err.name = "AssertionError";
# model
class Referral
attributes :ended_at, :datetime
end
# migration
class CreateReferrals ...
def change
create_table :referrals do |t|
...
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
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 August 10, 2018 17:23
An Introduction to Abstraction with Functions
function square(x) {
return x * x;
}
function area(r) {
return Math.PI * square(r);
}
function add1(x) {
return 1 + x;
<!-- HERE IS A COMMENT -->
<!--
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"'
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"