Skip to content

Instantly share code, notes, and snippets.

# ----------------------------------------------------------------------
# phplex.py
#
# A lexer for PHP.
# ----------------------------------------------------------------------
import ply.lex as lex
# todo: end-of-line comments containing ?>
# todo: double-quoted strings
<?php
$lines = array();
while (!feof(STDIN)) {
$line = fgets(STDIN);
if ($line === false) break;
$lines[] = $line;
}
$data = implode('', $lines);
$tokens = token_get_all($data);
$line_num = 0;
(defun move-region-up (arg)
(interactive "p")
(unless mark-active (mark-line 1))
(kill-region (region-beginning) (region-end))
(unwind-protect
(forward-line (- arg))
(yank))
(setq deactivate-mark nil))
(defun move-region-down (arg)
@ramen
ramen / Simple Tags vs. WP Taxonomies
Created November 2, 2010 00:35
The effect that the Simple Tags plugin has on $GLOBALS['wp_taxonomies']
--- without-simpletags.txt 2010-11-01 17:34:09.000000000 -0700
+++ with-simpletags.txt 2010-11-01 17:33:46.000000000 -0700
@@ -4,22 +4,16 @@
(
[hierarchical] => 1
[update_count_callback] => _update_post_term_count
- [rewrite] => Array
- (
- [hierarchical] => 1
- [slug] => category
@ramen
ramen / digable.tcl
Created January 24, 2011 15:30
Real-time probability-based beat generator
#!/bin/sh
#
# digable - Real-time probability-based beat generator
#
# Author: David Benjamin <[email protected]>
# Last updated: Mon Apr 30 20:54:52 MST 2001
#
# The next line restarts using wish \
exec wish "$0" "$@"
@ramen
ramen / default
Created January 24, 2011 15:31
Data file for digable.tcl
set ::DEFAULT_BPM 95
set ::KICK_PROBS { 1.000 0.125 0.625 0.125 0.000 0.000 0.125 0.500 \
0.000 0.125 1.000 0.250 0.000 0.250 0.000 0.250 }
set ::SNARE_PROBS { 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.250 \
0.000 0.625 0.000 0.000 1.000 0.000 0.000 0.000 }
set ::KICK_VOLS { 127.0 16.00 80.00 16.00 0.000 0.000 16.00 64.00 \
0.000 16.00 127.0 32.00 0.000 32.00 0.000 32.00 }
set ::SNARE_VOLS { 0.000 0.000 0.000 0.000 127.0 0.000 0.000 32.00 \
0.000 80.00 0.000 0.000 127.0 0.000 0.000 0.000 }
set ::CLHH_PROBS { 1.000 0.000 1.000 0.000 1.000 0.000 1.000 0.000 \
@ramen
ramen / .emacs
Created March 27, 2011 15:21
Scribes-style .emacs
;; emacs startup emulating scribes editor
(setq load-path (cons "~/.emacs.d" load-path))
(require 'linum)
(require 'paredit)
(require 'redo)
(bar-cursor-mode 1)
(column-number-mode 1)
@ramen
ramen / .mrxvtrc
Created April 1, 2011 20:35
Tango-esque color scheme for mrxvt
Mrxvt.color0: #121212
Mrxvt.color1: #cc0000
Mrxvt.color2: Chartreuse4
Mrxvt.color3: #f57900
Mrxvt.color4: SkyBlue4
Mrxvt.color5: #6255bc
Mrxvt.color6: DarkTurquoise
Mrxvt.color7: #2e3436
Mrxvt.color8: #eeeeec
Mrxvt.color9: #ff0000
@ramen
ramen / colors.txt
Created April 2, 2011 03:53
My ANSI color scheme as hex and RGB values
#121212 18 18 18
#cc0000 204 0 0
#458b00 69 139 0
#f57900 245 121 0
#4a708b 74 112 139
#6255bc 98 85 188
#00ced1 0 206 209
#2e3436 46 52 54
#eeeeec 238 238 236
#ff0000 255 0 0
@ramen
ramen / php-repl
Created May 4, 2011 22:21
PHP command line interface
#!/usr/bin/env php
<?php // -*- php -*-
print("PHP version " . phpversion() . " on " . PHP_OS);
print(" (use Ctrl-D to exit)\n");
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGINT, SIG_IGN);
}