Skip to content

Instantly share code, notes, and snippets.

View oneup's full-sized avatar

Florian Hufsky oneup

View GitHub Profile
@oneup
oneup / httpd.conf.snip
Created December 10, 2009 14:01
apache2 redirect everything to index.html prevent loop
# apache 2 mod_rewrite no infinite redirect loops
RewriteEngine on
# still keep /static folder
RewriteCond %(REQUEST_URI) !^(\/static) [NC]
# don't rewrite index.html (prevents infinite loop)
RewriteRule !index\.html - [C]
# rewrite everything to index
RewriteRule .* /index.html [R]
@oneup
oneup / coldec.rb
Created October 15, 2009 12:09
rails styles find_by_* automethods
# make on_collision_with()
def self.register_collision_classes
result = instance_methods.grep(/^#{COLLISION_HANDLER_PREFIX}/).map do |method_name|
name_of_handled = method_name[/^#{COLLISION_HANDLER_PREFIX}_?(.*)/,1]
Game.referee.track(self.underscore_name,name_of_handled.empty? ? :any : name_of_handled)
end
end
////
//// 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;
#!/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
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
@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"
@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"
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
#!/usr/bin/ruby
#
# Generic TCP Server Example
require "GServer"
class Root < GServer
def initialize(port=10001, *args)
super(port, *args)
end
#!/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