Skip to content

Instantly share code, notes, and snippets.

View nasser's full-sized avatar
🛰️
save-lisp-and-die

Ramsey Nasser nasser

🛰️
save-lisp-and-die
View GitHub Profile
require "open-uri"
require "hpricot"
require "htmlentities"
require "json"
require "yaml"
Encoding.default_internal = Encoding.default_external = "UTF-8"
coder = HTMLEntities.new
ard = Arduino.new
setup do
ard.setup do
name_analog 0, "lr"
name_analog 2, "ud"
end
end
def joy_x; ard.lr - width/2 end
module UI
class Canvas
def initialize x, y, w, h
@pointer = Native.ofxuicanvas_new x.to_f, y.to_f, w.to_f, h.to_f
end
def font file
Native.ofxuicanvas_setFont @pointer, File.expand_path(file).to_ptr, true, true, true, 0.0, 150
end
@nasser
nasser / signature.rb
Created October 16, 2012 13:45
Signature matching
class Signature
def self.[] *sig
Signature.new sig
end
def initialize sig
@signature = sig
end
def === other
@nasser
nasser / profile
Created October 18, 2012 03:46
Zajal flower.rb profile
===== Thread 1 =====
Total running time: 20.791475699000003s
index % time self children called name
----------------------------------------------------------
[1] 99.8 0.00 20.75 1 Rubinius::Loader#script [1]
0.00 20.75 1 Rubinius::CodeLoader.load_script [2]
-------------------------------------------------------
0.00 20.75 1 Rubinius::Loader#script [1]
[2] 99.8 0.00 20.75 1 Rubinius::CodeLoader.load_script [2]
0.00 20.75 1 Rubinius::CodeLoader#load_script [3]
@nasser
nasser / symbols.rb
Last active December 16, 2015 21:20
require 'graphviz'
require 'graphviz/theory'
g = GraphViz.new( :G, :type => :digraph, :layout => 'dot' )
binaries = {}
symbols = {}
nodes = {}
def list_symbols file, exported
class ManyMessages < Dumbstore::App
text_id 'many'
def text params
10.times do
Dumbstore.twilio.sms.messages.create(
from:Dumbstore::NUMBER,
to:params['From']
body:"I will say hello to you every 30 seconds"
)
@nasser
nasser / everyunicode.rb
Created June 16, 2013 21:05
Write every graphical Unicode character to a file
# encoding: utf-8
require 'unicode_utils'
File.open('everyunicode.txt', 'w') do |file|
UnicodeUtils::Codepoint::RANGE.each do |i|
file.write("#{UnicodeUtils::Codepoint.new(i).to_s}\t") if UnicodeUtils.code_point_type(i) == :Graphic
end
end
@nasser
nasser / Another.md
Last active December 19, 2015 01:39

Or this?

// Parse string +path+ into nested objects within +object+ and assign
// the deepest key to +value+, without overwriting existing keys.
// Examples follow.
function parse(path, value, object) { }
parse("foo", 42, {}); // => { foo: 42 }
parse("foo.bar", 42, {}); // => { foo: { bar: 42 } }
parse("foo.bar.baz", 42, {}); // => { foo: { bar: { baz: 42 } } }
parse("foo", 42, { challenge: "accepted" }); // => { foo: 42, challenge: 'accepted' }
parse("foo.bar", 42, { challenge: "accepted" }); // => { foo: { bar: 42 }, challenge: 'accepted' }