Skip to content

Instantly share code, notes, and snippets.

@charles-dyfis-net
charles-dyfis-net / gist:1081213
Created July 13, 2011 20:13
trying to install vagrant and dependencies inside an rvm environment
$ rvm gemset create vagrant
'vagrant' gemset created (/home/cduffy/.rvm/gems/ruby-1.8.7-p352@vagrant).
$ rvm gemset use vagrant
$ cd ~/VC/vagrant
~/VC/vagrant$ gem install bundler --pre
Fetching: bundler-1.1.pre.5.gem (100%)
Successfully installed bundler-1.1.pre.5
1 gem installed
Installing ri documentation for bundler-1.1.pre.5...
Installing RDoc documentation for bundler-1.1.pre.5...
@charles-dyfis-net
charles-dyfis-net / definition.rb
Created July 24, 2011 19:33
CentOS-6.0 (i386) + RBEL Chef veewee definition
Veewee::Session.declare( {
:cpu_count => '1', :memory_size=> '384',
:disk_size => '10140', :disk_format => 'VDI',
:os_type_id => 'RedHat',
:iso_file => "CentOS-6.0-i386-bin-DVD.iso", :iso_src => "", :iso_md5 => "d7e57d6edaca1556d5bad2fa88602309", :iso_download_timeout => 1000,
:boot_wait => "10",:boot_cmd_sequence => ['<Esc>', 'linux text ks=http://%IP%:%PORT%/ks.cfg<Enter>'],
:kickstart_port => "7122", :kickstart_timeout => 10000,:kickstart_file => "ks.cfg",
:ssh_login_timeout => "100",:ssh_user => "vagrant", :ssh_password => "vagrant",:ssh_key => "",
:ssh_host_port => "7222", :ssh_guest_port => "22",
:sudo_cmd => "echo '%p'|sudo -S sh '%f'",
@charles-dyfis-net
charles-dyfis-net / template_tracing.py
Created September 6, 2011 21:13
Example of instrumenting jinja2 to trace template components
import contextlib
@contextlib.contextmanager
def trace_to_stderr(name):
"""Trivial proof-of-concept for tracing template rendering"""
print >>sys.stderr, 'ENTER: %s' % (name,)
yield
print >>sys.stderr, 'EXIT: %s' % (name,)
class trace_decorator(object):
def __init__(self, contextmgr_type, item_type, item_name, *args, **kwargs):
@charles-dyfis-net
charles-dyfis-net / gist:1424448
Created December 2, 2011 19:09
uWSGI thread dump trigger
# added in WSGI handler run by uUWSGI
import sys
import os.path
try:
import uwsgi
import threading
stack_dump_file = '/tmp/stack-dump-trigger' ## given as an example; put this somewhere better than /tmp
@charles-dyfis-net
charles-dyfis-net / gist:2909106
Created June 11, 2012 08:39
clojure.osgi aware nREPL middleware
(defn osgi-bundle-handler
"If the namespace currently associated with this REPL has an OSGi
bundle associated, use this to set osgi/*bundle* and
clojure.lang.Compiler/LOADER."
[h]
(fn [msg]
(let [ns-meta (meta (get (deref (:session msg)) #'clojure.core/*ns*))
bundle (and ns-meta (:clojure.osgi.core/bundle ns-meta))
classloader (or (:repl-classloader ns-meta)
(and bundle (osgi/bundle-class-loader bundle)))
@charles-dyfis-net
charles-dyfis-net / gist:2912188
Created June 11, 2012 19:38
Trawling Clojure's thread-local frames
(ns thread-utils)
(def ^:private frame-prev-field (doto (.getDeclaredField clojure.lang.Var$Frame "prev") (.setAccessible true)))
(def ^:private bindings-field (doto (.getDeclaredField clojure.lang.Var$Frame "bindings") (.setAccessible true)))
(def ^:private tbox-val-field (doto (.getDeclaredField clojure.lang.Var$TBox "val") (.setAccessible true)))
(def ^:private thread-locals-field (doto (.getDeclaredField Thread "threadLocals") (.setAccessible true)))
(def ^:private thread-local-map-field (doto (.getDeclaredField java.lang.ThreadLocal$ThreadLocalMap "table") (.setAccessible true)))
(def ^:private entry-value-field (doto (.getDeclaredField java.lang.ThreadLocal$ThreadLocalMap$Entry "value") (.setAccessible true)))
(defn all-threads []
</array>
<key>CFBundleExecutable</key>
<string>firefox</string>
<key>CFBundleGetInfoString</key>
<string>Firefox 13.0</string>
<key>CFBundleIconFile</key>
<string>firefox</string>
<key>CFBundleIdentifier</key>
<string>org.mozilla.firefox</string>
<key>CFBundleInfoDictionaryVersion</key>
@charles-dyfis-net
charles-dyfis-net / mvn-compile-output.txt
Created July 3, 2012 21:31
Reproducer for zi compile issue
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building zi_issue_repro
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/cduffy/VC/zi-issue-repro.gist/src/main/resources
[INFO] [zi:resources {execution: default-resources}]
[INFO] [compiler:compile {execution: default-compile}]
package repro;
import com.espertech.esper.client.*;
import com.espertech.esper.event.map.MapEventBean;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.dyfis</groupId>
<artifactId>esper-testcase</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Esper bug reproducer</name>