Skip to content

Instantly share code, notes, and snippets.

View bernerdschaefer's full-sized avatar

Bernerd Schaefer bernerdschaefer

View GitHub Profile
@bernerdschaefer
bernerdschaefer / string.rb
Created July 5, 2012 12:48 — forked from durran/string.rb
Safe encode input strings, when they can be flagged with the wrong encoding.
class String
def force_valid_encoding
find_encoding(Encoding.list.to_enum)
end
def safe_encode(name)
force_valid_encoding
encode(name, :undef => :replace, :invalid => :replace, :replace => "")
end
require "./state_machine"
class Lexer
include StateMachine
def initialize(source)
@source = source
@buffer = []
end
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export JRUBY_OPTS="--1.9"
with_env() {
env $([ -f ".env" ] && cat .env) $*
}
alias vim="/usr/local/Cellar/macvim/7.3-64/MacVim.app/Contents/MacOS/Vim"
diff --git a/colors/solarized.vim b/colors/solarized.vim
index 70f5223..b92327a 100644
--- a/colors/solarized.vim
+++ b/colors/solarized.vim
@@ -610,8 +610,10 @@ else
exe "hi! NonText" .s:fmt_bold .s:fg_base00 .s:bg_none
endif
exe "hi! StatusLine" .s:fmt_none .s:fg_base1 .s:bg_base02 .s:fmt_revbb
-exe "hi! StatusLineNC" .s:fmt_none .s:fg_base00 .s:bg_base02 .s:fmt_revbb
-exe "hi! Visual" .s:fmt_none .s:fg_base01 .s:bg_base03 .s:fmt_revbb
" This theme is based on Solarized-dark colors, combined
" with Powerline native colors
call Pl#Hi#Allocate({
\ 'black' : 16,
\ 'white' : 231,
\
\ 'darkestgreen' : 22,
\ 'darkgreen' : 28,
\ 'mediumgreen' : 70,
\ 'brightgreen' : 148,
## web frontend
# the web front-end queues up some work to do.
queue "document.process", document.attributes
## back-end workers
# listen for work that needs to be done
subscribe "document.process" do |document|
# notify the front end that we've started
@bernerdschaefer
bernerdschaefer / gist:2413524
Created April 18, 2012 13:22
lambda { return } exits method when passed as &block
def sync(items)
seen = {}
do_sync = lambda do |item|
return if seen[item]
seen[item] = true
end
items.each &do_sync
# cat .env
# MYVAR=1
#
# with_env ruby -e "p ENV['MYVAR']" # => 1
# ruby -e "p ENV['MYVAR']" # => nil
with_env() {
env $([ -f ".env" ] && cat .env) $*
}
# encoding: utf-8
require 'minitest/spec'
require 'minitest/autorun'
puts RUBY_DESCRIPTION
describe "Encoding conversions" do
def serialize(string)
begin
class Document
attr_reader :value
def initialize(value)
@value = value
end
end
class Criteria