Skip to content

Instantly share code, notes, and snippets.

Aaron Hamid ahamid

Block or report user

Report or block ahamid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ahamid
ahamid / gist:4064dc457a80ced1ab29
Created Oct 24, 2014
Express recursive route matching can overflow stack
View gist:4064dc457a80ced1ab29
var express = require("express");
var app = express();
var TOO_MANY = 8000;
function handler(req, res) {
res.send("handler");
}
// test higher routes, eventually you will get
@ahamid
ahamid / gist:715653
Created Nov 25, 2010
Conditional layout with devise
View gist:715653
class ApplicationController < ActionController::Base
layout :layout_by_resource
# choose different layout for devise
def layout_by_resource
if devise_controller?
"users"
else
"application"
@ahamid
ahamid / bootstrap-drupal-quercus.sh
Created Jan 24, 2011
Bootstrap Drupal 6.20 on Quercus
View bootstrap-drupal-quercus.sh
#!/bin/sh
DRUSH_TGZ=drush-All-versions-4.1.tar.gz
RESIN_TGZ=resin-4.0.14.tar.gz
MYSQL_DRIVER_TGZ=mysql-connector-java-5.1.14.tar.gz
function msg {
echo
echo -e "\033[31m $1 \033[39m"
@ahamid
ahamid / Rakefile
Created Feb 26, 2011
Variable visibility in Rakefile method
View Rakefile
target=ENV['TARGET'] || "whatever"
def helpful_helper(a)
# do something extremely helpful
puts "Visible? #{target}"
end
task :default do
puts "My target is #{target}"
helpful_helper("yo")
View gist:1019897
// Created on Feb 7, 2009
package snippet;
import java.math.BigDecimal;
public class Monad {
// this is our "side effect" ("amplified object")
public static class AnnotatedObject<T> {
public T o;
@ahamid
ahamid / gist:1129651
Created Aug 6, 2011
BinData + Veritas
View gist:1129651
class BinDataRelation < Veritas::Relation
def initialize(klass, io)
super([[:index, Integer]] + BinDataRelation.veritas_fields(klass), BinDataRelation.record_enumerator(klass, io))
end
protected
def self.veritas_fields(klass)
veritas_fields = []
for field in klass.fields
View gist:1347206
/**
* Allows for calling a method asynchronously and queueing pending callbacks to avoid
* race conditions.
*
* Example:
*
* function createUniverse(arg, callback) {
* // important stuff that should not run in parallel here
* callback(whatever);
* }
@ahamid
ahamid / gist:1380816
Created Nov 20, 2011
Rock segfaulting
View gist:1380816
https://github.com/ahamid/semblance/tree/break-rock
+ rm -r .libs rock_tmp
+ rock -lelf -v -m64 -Isrc -o=semblance src/semblance.ooc src/CallingConvention.ooc src/CodeSection.ooc src/DataSource.ooc src/Datum.ooc src/elf.ooc src/FakeISA.ooc src/Instruction.ooc src/ISA.ooc src/ISARegistry.ooc src/Parser.ooc src/ProgramObject.ooc src/semblance.ooc src/SimpleParser.ooc src/Statement.ooc
./make: line 5: 9359 Segmentation fault (core dumped) rock -lelf -v -m64 -Isrc -o=semblance src/semblance.ooc src/*.ooc
View art.rb
#!/usr/bin/env ruby
i=0.0
loop do
print " " * (padding + (Math.sin(i) * 5)),
"Art and technology do coexist, if you let them\n\n"
i += 0.1
sleep 0.03
end
@ahamid
ahamid / gist:1432300
Created Dec 5, 2011
Makefile with ld flags
View gist:1432300
objects = ../../../mk/kimg.o cpu-arch.o scr-print.o
fill = ../../../utils/fill
cpu_objects = main.o task.o pgrequest.o descriptor.o thread.o tss.o interrupt.o paging.o memory.o cpu-asm.o syscall-gates.o int.o pic.o state_switch.o stack_winding.o caps.o permissions.o ttrace.o
prt_objects = print.o vga.o
dependencies = main.d task.d descriptor.d thread.d tss.d interrupt.d paging.d memory.d print.d caps.d permissions.d ttrace.d
You can’t perform that action at this time.