Skip to content

Instantly share code, notes, and snippets.

View Trevoke's full-sized avatar
🎹
insert meme here.

Trevoke Trevoke

🎹
insert meme here.
View GitHub Profile
@schacon
schacon / classy_git.md
Created November 12, 2010 20:48
RubyConf Talk
#! /usr/bin/env ruby
status = DATA.flock(File::LOCK_EX | File::LOCK_NB)
if status == 0
puts "we have the lock..."
sleep
else
@bnadlerjr
bnadlerjr / gist:1829874
Created February 14, 2012 20:15
java test that will show your environment
@Test
public void dumpEnv() {
for (Map.Entry<String, String> entry : new TreeMap<String, String>(System.getenv()).entrySet()) {
System.out.println(entry);
}
}
@jacksonwillis
jacksonwillis / s.rb
Created April 10, 2012 21:33
Sentences as Ruby code
class S; def initialize *w; @s=w; end; def method_missing *w;@s<<w;self;end;def
to_ary;[@s.map{ |e| e=~/[\,\.\:\-\(\)\/\'\"]/?[e]:[" ",e] }.join.strip];end;end
def Object.const_missing(c);S.new c;end; ###### https://gist.github.com/2354740
puts This.is.a.sentence.represented.by.a.Ruby.expression(",").try.it.out! #####
@mig
mig / init.el
Created January 18, 2011 21:00
Simple Emacs 24 configuration for Rails development
;; emacs configuration
(push "/usr/local/bin" exec-path)
(add-to-list 'load-path "~/.emacs.d")
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
@moss
moss / exr.rb
Created August 11, 2013 19:24
#!/Users/moss/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
class Runner
def initialize basepath, executor = ExecutionService.new
@basepath = basepath
@executor = executor
@cmds_term = TmuxSession.new '0', executor
@test_term = TmuxSession.new '1', executor
end
#!/usr/bin/env python
"""
This script recursively searches the current directory for .vimrc files
and counts the number of times an option has been modified.
It currently only uses lines that start with 'set ', 'setlocal', 'let',
etc. are ignored.
"""

A small sampling of external projects initially built for Ember use but designed to be used standalone:

The logical relations between Go scoring systems

What is the simplest Go scoring system? It's this:

  • Stone Scoring: just count the stones on the board

At the end of the game, both players will want to fill in as much of their own territory as they can, while allowing two eyes per group (so they aren't captured). Then the winner is just the player with more stones on the board. Note that prisoners are not counted.

But nobody wants to play all these extra stones at the end. So we can instead use:

@threeifbywhiskey
threeifbywhiskey / legibler_brainfuck.rb
Last active August 19, 2016 01:45
This is a brainfuck interpreter written using little more than lambdas, numbers, and a whole lot of symbols.
SIZE = -> coll {
coll == [] || coll == '' ? 0 : 1 + SIZE[coll[1..-1]]
}
MAP = -> coll, &fn {
coll == [] ? [] : [fn[coll[0]]] + MAP[coll[1..-1], &fn]
}
KEYS = -> hash { MAP[[*hash], &-> h { h[ 0] }] }
VALUES = -> hash { MAP[[*hash], &-> h { h[-1] }] }