Skip to content

Instantly share code, notes, and snippets.

View elorest's full-sized avatar

Isaac Sloan elorest

View GitHub Profile
xdef distance(a, b)
return a.length if (0 == b.length)
return b.length if (0 == a.length)
unpack_rule = ($KCODE =~ /^U/i) ? 'U*' : 'C*'
mapper = lambda{|str|
str = str.unpack(unpack_rule)
map = []
str.each_with_index {|letter,idx|
@elorest
elorest / isaac_tmate.sh
Created April 2, 2014 23:38
isaac tmate
# placeholder for domains to ssh into.
require 'rrobots'
class Elorest
include Robot
def tick events
@time = "hello" if time == 0
say @time
# @planned ||= events['robot_scanned'].inspect
# say @planned
require "socket"
UNIXSocket.open("/tmp/cr.sock") do |sock|
puts "What is your name?"
name = gets
sock.puts name
puts sock.gets
sock.close
end
#include <stdio.h>
struct Person{
char * name;
char * height;
int age;
};
void hello_ptr(const struct Person * p){
@[Link(ldflags: "#{__DIR__}/say.o")]
@[Link("m")]
lib LibSay
struct Person
name : UInt8*
height : UInt8*
age : Int32
end
@elorest
elorest / helloworld.cr
Last active July 14, 2017 04:50
Cbinding Hello World Example
{% `gcc -c say.c` %} # Uses macro to compile object file before compile time.
@[Link(ldflags: "#{__DIR__}/say.o")]
@[Link("m")]
lib LibSay
struct Person
name : UInt8*
height : UInt8*
age : Int32
end
require "socket"
UNIXSocket.open("/tmp/cr.sock") do |sock|
puts "What is your name?"
name = gets
sock.puts name
puts sock.gets
sock.close
end
@[Link(ldflags: "#{__DIR__}/say.o")]
@[Link("m")]
lib LibSay
struct Person
name : UInt8*
height : UInt8*
age : Int32
end
macro parse_yaml(filename)
{{ run("./yamlparser.cr", filename) }}
end
parse_yaml("tmp.yml")
puts dev["array"]
puts prod["array"]