Skip to content

Instantly share code, notes, and snippets.

@moret
moret / Monokai Revisited.dvtcolortheme
Created June 4, 2014 18:55
~/Library/Developer/Xcode/UserData/FontAndColorThemes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.995968 0.995968 0.995968 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>BitstreamVeraSansMono-Bold - 14.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.995968 0.995968 0.995968 1</string>
@moret
moret / Rakefile
Created April 9, 2014 22:03
Example using NewRelic with after_fork for Unicorn but always doing so even for Resque workers
require 'rubygems'
require 'bundler/setup'
class SomeJob
@queue = :some_queue
def self.perform
puts 'working - actually, sleeping...'
sleep 1
puts 'done'
def symbolize obj
if obj.is_a? Hash
new_hash = {}
obj.each { |key, value| new_hash[key.to_sym] = symbolize value }
new_hash
elsif obj.is_a? Enumerable
obj.collect { |value| symbolize value }
else
obj
end
@moret
moret / gist:8304660
Created January 7, 2014 18:58
My answers to Regex Golf @ http://regex.alf.nu/
Plain strings (207): foo
Anchors (208): k$
Ranges (202): [a-f]{4}
Backrefs (201): (...).*\1
Abba (193): ^(?!.*(.)(.)\2\1)
A man, a plan (177): ^(.)[^p].*\1$
Prime (286): ^(?!(..+)\1+$)
Four (199): (.)(.\1){3}
Order (188): ^[abcdfgm](?![nar]|id)
Triples (0):
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
$ ./configure --with-ld-opt='-L/usr/local/lib/' --with-cc-opt='-I/usr/local/include/' --add-module=../nginx-push-stream-module --prefix=./build
checking for OS
+ Darwin 13.0.0 x86_64
checking for C compiler ... found
checking for --with-ld-opt="-L/usr/local/lib/" ... found
class Player
def play_turn(warrior)
unless @explored_left
@explored_left = false
return warrior.pivot!
end
fwd = @explored_left ? :forward : :backward
rew = !@explored_left ? :forward : :backward
@moret
moret / hello_lib.c
Created March 1, 2013 14:25
hello_lib
#include <stdio.h>
#include <my_lib.h>
int main(void) {
printf("%s", my_function());
}
/*
Build me with:
@moret
moret / gist:5032232
Created February 25, 2013 18:52
Merge some branch, commits it all at master as a single commit
# Updates if needed
git checkout master
git fetch
git pull
# Merge and reset
git merge whatever_branch
git reset origin/master
# Commits everything as a single commit
@moret
moret / robot.js
Created December 6, 2012 12:49
turr
var Robot = function(robot) {};
Robot.prototype.onIdle = function(e) {
var r = e.robot;
r.turn();
r.fire();
r.ahead();
};
Robot.prototype.onScannedRobot = function(e) {
@moret
moret / robot.js
Created December 6, 2012 12:26
rotate the pod bay doors please hal
var Robot = function(robot) {
this.longAgo = 50;
this.spot = this.longAgo;
};
Robot.prototype.onIdle = function(e) {
var r = e.robot;
r.fire();
if (this.spot > this.longAgo) {
r.rotateCannon();