Skip to content

Instantly share code, notes, and snippets.

@edubkendo
edubkendo / daemon.rb
Created September 18, 2013 14:01 — forked from ik5/daemon.rb
#!/usr/bin/env jruby
#
#
require 'rubygems'
require 'spoon'
EXEC = '/tmp/exec.rb'
PID_PATH = '/tmp/exec.pid'
WORK_PATH = '/tmp/'
@edubkendo
edubkendo / RubyNext.tmLanguage
Created August 10, 2013 03:58
A better ruby syntax highlighter for sublime text. Combines the ruby bundle with ST, recent updates to the textmate bundle, and a tmLanguage file called "Experimental Ruby".
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>
TODO: unresolved issues
text:
@enebo
enebo / heh.java
Last active December 20, 2015 09:19
private static Node find(Node oldRoot, Node oldObject, Node newRoot) {
// Walk down the tree to locate oldObject, and in the process, pick the same child for newRoot
List<?extends Node> oldChildren = oldRoot.childNodes();
List<?extends Node> newChildren = newRoot.childNodes();
Iterator<?extends Node> itOld = oldChildren.iterator();
Iterator<?extends Node> itNew = newChildren.iterator();
while (itOld.hasNext()) {
if (!itNew.hasNext()) {
return null; // No match - the trees have changed structure
@colinsurprenant
colinsurprenant / CallJRuby.java
Last active December 31, 2018 04:59
calling JRuby from Java example
import org.jruby.Ruby;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.RubyClass;
import org.jruby.RubyModule;
public class CallJRuby {
private static final Ruby __ruby__ = Ruby.getGlobalRuntime();
App = require('app')
App.PagesView = Em.View.extend
templateName: require('templates/pages')
click: (event) ->
# console.log event
elem = event.srcElement
x = event.pageX
y = event.pageY
@JoshCheek
JoshCheek / io_and_its_spec.rb
Created May 11, 2013 19:07
Example of beginning to test the Io class for a Tic tac Toe game, for Phil
require 'stringio'
class Io
attr_accessor :instream, :outstream
def initialize(instream, outstream)
self.instream = instream
self.outstream = outstream
end
ext-jruby-local ~/projects/jruby $ jirb
irb(main):001:0> obj = java.lang.Object.new
=> #<Java::JavaLang::Object:0x7f6673fa>
irb(main):002:0> obj.getClass
=> class java.lang.Object
irb(main):003:0> _.class
=> Java::JavaLang::Class
irb(main):004:0> jcls = java.lang.Object.java_class
=> class java.lang.Object
irb(main):005:0> jmethod = jcls.declared_method(:getClass)
@beaufour
beaufour / pre-commit-runner.bash
Created April 2, 2013 13:40
A git commit hook runner, for running multiple commit scripts
#!/bin/bash
#
# Collection of pre-commit hooks
#
set -e
# Get directory of script file
ME=$0
if [ -h ${ME} ]; then
@beaufour
beaufour / todo-check.py
Created April 2, 2013 13:39
Git commit hook to check for lines with "TODO" in them
#!/usr/bin/python
import logging
import re
import sys
import envoy
def _exec_git(cmd, args=''):
cmd = 'git {0} --color=never {1}'.format(cmd, args)
@ehaliewicz
ehaliewicz / compiler.lisp
Last active December 14, 2015 11:19
Compiler inlining example
;; 'val is the register where the return value of compiling goes
;; 'next is the requested type of compiler linkage, how the compiler will finish off the compiled code
;; 'return linkage returns to the state on top of the stack (to return from a function)
;; 'next linkage just continues onto whatever is the next instruction after the compiled instructions
;; any other linkage assumes a label,
;; i.e. (compile '(+ 1 2 3) 'val 'end) assumes 'end is a label somewhere,and jumps to it after calculating (+ 1 2 3)
(statements (ec-compile '(+ 1 2 3) 'val 'next)) ;; compile without inlining/open-coding
=>