This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# Generic TCP Server Example | |
require "GServer" | |
class Root < GServer | |
def initialize(port=10001, *args) | |
super(port, *args) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
# | |
# IRC Client Example | |
require "socket" | |
# Don't allow use of "tainted" data by potentially dangerous operations | |
$SAFE=1 | |
# The irc class, which talks to the server and holds the main event loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//// | |
//// OpenGL based server that streams images to screen from multiple clients | |
//// maybe someone can use this / have fun playing with it | |
using System; | |
using System.Text; | |
using System.Collections; | |
using System.Threading; | |
using System.IO; | |
using System.Net.Sockets; |
OlderNewer