View Particle_extention.java
public class BoxParticle extends Particle { | |
int color; | |
int size; | |
public BoxParticle(PVector location, int color, int size) { | |
super(location); | |
this.color = color; | |
this.size = size; | |
} |
View base_62_converter.py
#!/usr/bin/env python | |
# | |
# Converts any integer into a base [BASE] number. I have chosen 62 | |
# as it is meant to represent the integers using all the alphanumeric | |
# characters, [no special characters] = {0..9}, {A..Z}, {a..z} | |
# | |
# I plan on using this to shorten the representation of possibly long ids, | |
# a la url shortenters | |
# |
View remembrances.rb
# Learning ruby, trying to remember these fun facts | |
#--ARRAYS | |
#--#--Useful functions | |
[1, 2, 3, 4].any? {|n| n > 2} #=> true | |
[1, 2, 3, 4].all? {|n| n > 2} #=> false | |
#--#--collect and map (collect! and map!) | |
a = [ "a", "b", "c", "d" ] |
View binary_sort.rb
class BinaryTree | |
attr_accessor :value, :left, :right | |
def insert(value) | |
if @value | |
if value < @value | |
@left ||= BinaryTree.new | |
@left.insert(value) | |
else |
View deep_write.rb
require 'fileutils' | |
def deep_write(f, data) | |
FileUtils.mkdir_p(File.dirname(f)) unless File.directory?(File.dirname(f)) | |
File.open(f, 'w').write(data) | |
end |
View index.html
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Websockets tail Server</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script src="/socket.io/socket.io.js"></script> | |
<style type="text/css" rel="stylesheet"> | |
body{background-color:#222;} | |
#info{ font-size: 32px; color:#000;text-shadow:#444 1px 1px 2px; text-align:right;margin:20px 10px;text-transform:lowercase;} |
View libtre_test.c
Compiled Regex | |
Created Default params | |
cost_ins -> 1 | |
cost_del -> 1 | |
cost_subst -> 1 | |
max_cost -> 2147483647 | |
max_ins -> 2147483647 | |
max_del -> 2147483647 | |
max_subst -> 2147483647 | |
max_err -> 2147483647 |
View reduce_flags.rb
REG_EXTENDED = 1 | |
REG_ICASE = (REG_EXTENDED << 1) | |
REG_NOSUB = (REG_ICASE << 1) | |
REG_NEWLINE = (REG_NOSUB << 1) | |
flags = [REG_EXTENDED, REG_NOSUB] | |
p flags.reduce :| | |
# => 5 |
View pry_trick.rb
require 'pry' | |
class Object | |
LABELS = [:label1, :label2] | |
def breakpt(label, target=self) | |
LABELS.include?(label) ? Pry.start(target) : nil | |
end |
View rb.js
// kind of like ruby openstruct | |
var OpenObject = function () { | |
this.construct = function (defaults, params) { | |
for (var attr in defaults) this[attr] = defaults[attr]; | |
for (var attr in params) this[attr] = params[attr]; | |
}; | |
} | |
var Circle = function (opts) { |
OlderNewer