Skip to content

Instantly share code, notes, and snippets.

View oneup's full-sized avatar

Florian Hufsky oneup

View GitHub Profile
@oneup
oneup / gist:74071
Created March 4, 2009 23:01
thoughts
online code repository for ruby/game code.
game client fetch from library & cache
ruby, gosu, opengl, bastardshell (OS/3)
evil idea:
use gist as code editor with highlighting (for JSmalltalk)
requires cross_domain_xhr_transport ]] cross_domain_ajax
# that would be so cooL!
def safe_eval(text)
begin
Kernel.eval(text)
rescue Exception => e
"Exception " + e.to_s
rescue SyntaxError => e
"Syntax Error #{e}"
rescue Error => e
"Error #{e}"
rescue NameError => e #"multicast" nameerror, so inventory can caputre it
@oneup
oneup / conventions
Created July 6, 2009 01:12
eat l337 suckahs
repl: [up] is the last used line (cycles upwards)
text: #foo is a tag; @foo likewise, but informs user (object with that name)
repl alias shell
@oneup
oneup / quartz iphone draw circle
Created July 8, 2009 17:04
teaches how to draw a circle using iphone sdk quartz stuff
- (void)makeCircleAt:(CGPoint)center withDiameter:(float)diameter withColor:(int)myColor
{
float radius = diameter * 0.5;
CGRect myOval = {center.x - radius, center.y - radius, diameter, diameter};
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextAddEllipseInRect(context, myOval);
CGContextFillPath(context);
}
#!/usr/bin/ruby
#
# check for collisions between two circles
# we can compare the squared radius/distance instead of comparing squareroots because of math.
def circles_collide (x1, y1, radius1, x2, y2, radius2)
# compare the distance to combined radii
distance_x = x2 - x1
distance_y = y2 - y1
#!/usr/bin/ruby
#
# Generic TCP Server Example
require "GServer"
class Root < GServer
def initialize(port=10001, *args)
super(port, *args)
end
void *c_core(void*root){
//evaluates root (scripting language with byte input)
return null;
}
/* // eg
c_core(); // crash / null -> undefined
c_core(null); //
c_core("puts hello world"); // scan for \0, puts (report) findings
c_core("console"); // initialize screen and open console
@oneup
oneup / q3_autoexec.cfg
Created July 15, 2009 21:15
widescreen quake 3 is nicer , also GL_NEAREST
// Quake 3
// config for iMac 2.4 GHz Core 2 Duo
// custom aspect ratio for 1680x1050 wide-screen
//
seta r_mode "-1"
seta r_fullscreen "1"
seta r_customheight "1050"
seta r_customwidth "1680"
@oneup
oneup / what_i_used_from_rails.rb
Created July 18, 2009 05:34
useful rails cheatsheet
# Rails Cheat Sheet
# and list of helpers worth keeping
# command line
script/generate controller
# route
map.root :controller => "controller_name"
require 'benchmark'
Benchmark.bm do |bm|
bm.report('ruby:') do
100000.times { 8.factorial }
end
bm.report('c:') do
100000.times { CFactorial.factorial(8) }
end