Skip to content

Instantly share code, notes, and snippets.

View oranj's full-sized avatar
👁️‍🗨️
Observing

Raymond Roeming oranj

👁️‍🗨️
Observing
View GitHub Profile
@oranj
oranj / mc_modloader.sh
Created November 8, 2012 04:54
Automagically Loads Minecraft Mod
This is a mac specific script to load a mod into minecraft. In the terminal, run:
./mc_modloader.sh ModName.zip.
It will make a backup of your current minecraft jar, and attempt to merge the mod into it.
@oranj
oranj / tab.sh
Created October 11, 2012 15:46
Engine to watch files
#This file lists a bunch of callbacks for file changed events.
#@ /Users/raym/Sites/myon/includes/content/js/reader/player.3.2.js
java -jar $HOME/Sites/myon/server/utils/rm/lib/yuicompressor-2.4.7.jar /Users/raym/Sites/myon/includes/content/js/reader/player.3.2.js -o /Users/raym/Sites/myon/includes/content/js/reader/player.min.3.2.js;
echo "Hello world";
@oranj
oranj / best_fit.php
Created October 1, 2012 21:28
Best fit
function calculate_line($x1, $y1, $x2, $y2, $dataset) {
$m = ($y2 - $y1) / ($x2 - $x1);
$b = ($y1 - $m * $x1);
$total_diff = 0;
foreach ($dataset as $inf) {
list($x, $y) = $inf;
$yl = $m * $x + $b;
$diff[$x] = $yl - $y;
$total_diff += abs($diff[$x]);
@oranj
oranj / pre-commit
Created September 7, 2012 20:06
Pre commit hook.
#!/usr/bin/php
<?php
chdir (dirname(__FILE__).'/../../');
$root = realpath(getcwd()).'/';
define('ESC', "\033");
function is_tty() {
static $is_tty = null;
if (is_null($is_tty)) { $is_tty = posix_isatty(STDOUT); }
@oranj
oranj / params.js
Created August 23, 2012 19:51
Get parameters of any non native functions
function getParameters(method) {
var sig = method.toString();
var matches = sig.match(/function\s*\((.*?)\)/);
if (matches == null || ! matches.length) {
return [];
}
return matches[1].split(/,\s*/);
};
@oranj
oranj / combos.php
Created August 20, 2012 19:38
Generate Combinations of a set
<?php
function generate_combinations($set, $max_depth = INF, $depth = 0) {
if (! is_array($set)) { trigger_error("Give me an array plox"); }
if (count($set) <= 1) {
return array($set);
}
if ($depth >= $max_depth) {
return array($set);
}
@oranj
oranj / gist:3182646
Created July 26, 2012 15:17
Javascript wrapper for cross domain requests.
var XReq = function(params) {
this.init(params);
this.perform();
}
XReq.prototype = {
'init': function(params) {
var members = {
'url':null,
@oranj
oranj / prune.php
Created July 10, 2012 15:57
Javascript Function Pruner
<?php
if (count($argv) < 2) {
die("Please enter a filename");
}
$filename = $argv[1];
$funcNameRegex = '(?P<func>[a-zA-Z0-9_$]+)';
$contents = file_get_contents($filename);
@oranj
oranj / Shelly.php
Created May 18, 2012 19:49
Shell based application rendering system.
<?php
class ShellItem {
const SIZE_MODE_SCALE = 0;
const SIZE_MODE_CONST = 1;
private $width;
private $height;
private $width_mode;
@oranj
oranj / sphere.php
Created May 17, 2012 19:02
Generate Sphere
<?php
$is_shell_script = ! isset($_SERVER['REQUEST_URI']);
$width = $height = $depth = 5;
$hollow = false;
if ($is_shell_script) {
for ($i = 1; $i < $argc; $i++) {