Skip to content

Instantly share code, notes, and snippets.

@chanchalg
chanchalg / unflattentree.js
Created January 20, 2011 12:19
normalize an object tree, graph
function ksplit(name, lookupspace){
var parts = name.split('.');
var current = lookupspace;
for (var i in parts) {
print(i + " " + parts[i]);
if (!current[parts[i]]) {
print(" not there: " + parts[i]);
current[parts[i]] = {};
}
current = current[parts[i]];
@chanchalg
chanchalg / mrisc.rb
Created July 8, 2011 01:42 — forked from pachacamac/mrisc.rb
A Simple Assembler Language and VM
#!/usr/bin/env ruby
class MRISC
def run(code)
tokens = code.gsub(/(\*.*?\*)|[^a-z0-9,-;@\._]/,'').split(';')
@vars,stack,i = {:_pc=>-1,:_oc=>0},[],0
tokens.map!{|t| t.chars.first=='@' ? (@vars[t.to_sym]=i-1;nil) : (i+=1;t.split(',').map{|e|numeric?(e) ? e.to_i : e.to_sym})}.compact!
while @vars[:_pc] < tokens.size-1
@vars[:_pc] += 1
@vars[:_oc] += 1
@chanchalg
chanchalg / Google Closure.sublime-build
Created February 17, 2012 21:42 — forked from insin/Google Closure.sublime-build (Linux)
Google Closure Compiler build for Sublime Text 2
{
"cmd": ["java", "-jar", "${packages}/Google Closure/compiler.jar", "--js", "$file", "--js_output_file", "/dev/null", "--compilation_level", "WHITESPACE_ONLY"],
"file_regex": "^(.*):([0-9]+):() ERROR - (.*)",
"selector": "source.js"
}
@chanchalg
chanchalg / table.html
Created July 11, 2012 02:30 — forked from dunhamsteve/table.html
Example of a scrollable table that only renders visible rows
<html>
<style type="text/css" media="screen">
#table {
position: absolute;
top: 30px;
bottom: 0;
left: 10px;
right: 10px;
}
#header {
@chanchalg
chanchalg / conf.nmap
Created July 12, 2012 19:50 — forked from sygo/conf.hexdump
additions to the standard grc.conf (check the appropriate conf files for each command)
# ip number
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
colours=bold yellow
======
# list header
regexp=(PORT|STATE|SERVICE|REASON|VERSION)
colours=bold white
======
# open
regexp=open
@chanchalg
chanchalg / conf.apache
Created July 12, 2012 19:57 — forked from vjt/conf.apache
GRC (Generic Colouriser/Colorizer) configuration for Apache / nginx access logs
# Configuration suitable to display Apache/nginx access logs
# Based on conf.proftpd by Pavol Domin
# Crafted by Marcello Barnaba <vjt@openssl.it>
# Get GRC at http://kassiopeia.juls.savba.sk/~garabik/software/grc.html
#
# ip number
regexp=^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
colours=bold magenta
Robot r = new Robot();
System.out.println("Start!");
Thread.sleep(2000); // give yourself some margin to switch window
int[] times = { 1, 5, 4, 4, 1, 3, 2 }; // number of shots for each distance
int[] delays = { 400, 400, 575, 820, 850, 1150, 1350 }; // time holding the ball
int[] delays2 = { 200, 650, 700, 600, 400, 450, 400 }; // time waiting for a new ball
for (int i = 0; i < times.length; i++)
for (int j = 0; j < times[i]; j++) {
r.keyPress(KeyEvent.VK_SPACE);
r.delay(delays[i]);
@chanchalg
chanchalg / new_bashrc.sh
Created August 11, 2012 07:41 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
@chanchalg
chanchalg / LICENSE.txt
Created August 14, 2012 07:10 — forked from atesgoral/LICENSE.txt
Variable-argument string formatter with {token} syntax that supports object properties and argument indices
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Ates Goral <http://magnetiq.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@chanchalg
chanchalg / rss-subscribers.sh
Created September 25, 2012 22:44
Bash script to parse Apache log for a count of RSS subscribers and email it to you
#!/bin/bash
# Schedule this to run once a day with cron. Doesn't matter what time since it parses yesterday's hits (by default).
# I only tested this on the Marco.org server, which runs CentOS (RHEL). No idea how it'll work on other distributions, but it's pretty basic.
# Required variables:
RSS_URI="/rss"
MAIL_TO="your@email.com"
LOG_FILE="/var/log/httpd/access_log"