Skip to content

Instantly share code, notes, and snippets.

View bcardiff's full-sized avatar
🏝️
I should be slow to respond.

Brian J. Cardiff bcardiff

🏝️
I should be slow to respond.
View GitHub Profile
@bcardiff
bcardiff / base.cr
Created June 18, 2014 20:36
file system abstraction for crystal
macro collect_alias_method(method, type)
def {{method}}
res = [] of {{type}}
{{method}} do |e|
res << e
end
res
end
end
@bcardiff
bcardiff / todos.rb
Last active August 29, 2015 14:14
List of TODOs in ./app/ decorated with blame sorted by time git grep blame
require 'date'
target = ARGV[1] || "."
files = %x(git grep -n 'TODO*' #{target})
lines = []
length_author = 0
length_file = 0
@bcardiff
bcardiff / README.md
Created June 19, 2015 08:24
Autocode metaprogramming POC in Crystal

Compiling

crystal build main.cr

will change Settings declaration in main.cr from

class Settings
@bcardiff
bcardiff / .gitignore
Last active August 29, 2015 14:23
Crystal spike of Haskell like data
.crystal
@bcardiff
bcardiff / 00-README.md
Last active August 29, 2015 14:24
fsm from a ruby way to a crystal way

This intent to show how Ruby practice can be addapted to Crystal. With a total different under the hood implementation, but keeping some of the greatest aspects.

The focus thou is not to stand on how a fsm should be modeled, or defined by a dsl, BUT how some common Ruby practices might be rethinked to take advantage of Crystal.

As an intermediate step, I sometimes like to think in a more plain type/classes design to have a nice compile time experience, but using macros in crystal to reach that from a nice dsl.

NB: There is consideration to name the examples a language way and not the language way .

@bcardiff
bcardiff / keybase.md
Created August 31, 2015 18:30
keybase.md

Keybase proof

I hereby claim:

  • I am bcardiff on github.
  • I am bcardiff (https://keybase.io/bcardiff) on keybase.
  • I have a public key whose fingerprint is A2BC 755E D6EE AC60 6C7E D13D 2BFD 635A 00D0 2045

To claim this, I am signing this object:

@bcardiff
bcardiff / repro331-228-2015-09-02.mba
Created September 2, 2015 15:33
mbuilder repro 331
{"tables":[{"name":"Trackers","guid":"bb1c463d-b35f-4fb0-a18b-78fab5f25963","kind":"local","fields":[{"name":"Phone","guid":"abf4aca1-502c-43f6-acad-0f88c33340fc","valid_values":""}],"protocol":["query","update","insert"]}],"message_triggers":[{"name":"track","enabled":true,"message":{"from":"+1-(234)-567-8912","pieces":[{"kind":"text","text":"track","guid":"815fa0f2-cfd7-4863-94d8-92fdb1430cdd"}],"pattern":"(?i-mx:\\A\\s*track\\s*\\Z)"},"kind":"message_trigger","actions":[{"kind":"create_entity","table":"bb1c463d-b35f-4fb0-a18b-78fab5f25963","field":"abf4aca1-502c-43f6-acad-0f88c33340fc","pill":{"kind":"placeholder","guid":"phone_number"}},{"kind":"send_message","message":[{"kind":"text","guid":"you are been tracked"}],"recipient":{"kind":"placeholder","guid":"phone_number"}}]},{"name":"all","enabled":true,"message":{"from":"+1-(234)-567-8912","pieces":[{"kind":"text","text":"all","guid":"0e2be89a-85dc-4eaf-b988-38f88ff0c9aa"},{"kind":"placeholder","text":"lorem ipsum","guid":"f02701b4-d99f-446b-aa90-39291f7
@bcardiff
bcardiff / tests.cpp
Created September 19, 2012 19:44
tp0 test
#include "anillo.h"
#include "aed2_tests.h"
template<typename T>
string to_s(const Anillo<T>* a) {
ostringstream os;
os << *a;
return os.str();
}
@bcardiff
bcardiff / aed2_tests.h
Created November 28, 2012 19:07
tp3 test
#ifndef AED2_TESTS_
#define AED2_TESTS_
#include <iostream>
#include <sstream>
using namespace std;
string mt_bool_to_s(bool b) { return b ? "true" : "false"; }
#define MT_MAKE_ERROR(lhs, rhs, line) { ostringstream os;os << "error en linea " << (line) << endl;os << " se esperaba: " << (rhs) << endl;os << " se obtuvo: " << (lhs);throw os.str(); }
void mt_assert(bool lhs, bool rhs, int line) { if (lhs != rhs) { MT_MAKE_ERROR(mt_bool_to_s(lhs), mt_bool_to_s(rhs), line) } }
@bcardiff
bcardiff / README.md
Last active November 17, 2015 01:06
p5e1

INTRODUCTION TO PROGRAMMING FOR THE VISUAL ARTS WITH P5.JS

Assignment 1: Port an Image to Code