Skip to content

Instantly share code, notes, and snippets.

View simeonwillbanks's full-sized avatar
☀️
😎

Simeon Willbanks simeonwillbanks

☀️
😎
View GitHub Profile
@simeonwillbanks
simeonwillbanks / utf8able.rb
Created June 8, 2012 17:31
Mixin Idea To Force UTF-8 #rails #ActiveRecord #utf8 #mixin
module Utf8able
extend ActiveSupport::Concern
included do
before_save do
# introspect attributes
# filter on text like
# force_utf8
end
end
@simeonwillbanks
simeonwillbanks / proof of concept.txt
Created May 26, 2012 04:27
taskmapper-redmine issue notes #Taskmapper #gem #redmine #OpenSource
http://www.hostedredmine.com/issues/67867
$ irb -r rubygems -r taskmapper -r /Users/simeon/Projects/taskmapper-redmine/lib/taskmapper-redmine
>> RedmineAPI.authenticate('http://www.hostedredmine.com/', '999e4b8688e8dba3eee9515548e203c5bea5f019')
=> "http://www.hostedredmine.com/"
>> issue = RedmineAPI::Issue.find(67867, :params => {:include => 'journals'})
=> #<RedmineAPI::Issue:0x007fa28c0a0808 ...
>> issue.journals[0].notes
=> "I've read through the introductory ns3 stuff and will be saving the Contiki documentation for next week."
>> issue.journals[1].notes
@simeonwillbanks
simeonwillbanks / console.rb
Last active October 1, 2015 14:38
Multibyte Testing: figure out the best way to handle 'ArgumentError: invalid byte sequence in UTF-8' exceptions
=> "Résumé"
>> invalid = str + "\xc3\x28" # add accent and ( which invalidates string, http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=string-literal&unicodeinhtml=hex
=> "Résumé\xC3("
>> str.is_utf8?
=> true
>> invalid.is_utf8?
=> false
>> result = invalid.force_encoding(Encoding::ASCII_8BIT).encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace, :replace => '') # converting to ascii destroys valid utf8
=> "Rsum("
>> result.is_utf8?
@simeonwillbanks
simeonwillbanks / Gemfile
Created January 26, 2012 23:18
#gemfile rails 3, rspec-rails, capybara, capybara-webkit, headless in order to run request specs that can test javascript
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@simeonwillbanks
simeonwillbanks / encapsulated_hash.rb
Created January 19, 2012 21:54
#Rails Params Hash Encapsulated #ruby #method_missing
class EncapsulatedHash
def initialize(h)
@encapsulated = ActiveSupport::HashWithIndifferentAccess.new
h.each_pair {|key, value| @encapsulated[key] = value }
end
def method_missing(m, *args, &block)
if @encapsulated.respond_to? m
@encapsulated.send(m, *args, &block)
@simeonwillbanks
simeonwillbanks / gist:1335255
Last active September 27, 2015 21:38
#commandline One liners
$ ps -ef | grep resque | grep -v grep | awk '{ print $2 }' | xargs kill; echo '* stopped all resque workers.'
$ find . -name \*.rb| xargs grep -n "SLASH_PLACEHOLDER"
$ git log --author simeon --pretty=oneline | grep -v Merge > ~/git-log.txt
% wget --mirror -p --html-extension --convert-links http://www.acm.uiuc.edu/workshops/zsh/
@simeonwillbanks
simeonwillbanks / fizzbuzz.js
Created October 31, 2011 19:05
#JavaScript #FizzBuzz #ProgrammingChallenge
(function(){for (var i = 1; i<=100; i++) { if (i % 3 == 0 && i % 5 == 0) {console.log("FizzBuzz");} else if (i % 3 == 0) {console.log("Fizz")} else if (i % 5 == 0) {console.log("Buzz");} else {console.log(i);} }})();
@simeonwillbanks
simeonwillbanks / MacVim-Janus.md
Created October 12, 2011 22:51 — forked from jraines/MacVim-Janus.md
Readme: Macvim & Janus #readme

##Intro

Janus is a "basic distribution of vim plugins and tools intended to be run on top of the latest MacVIM snapshot." It is maintained by Yehuda Katz and Carl Lerche.

I recently whinged on Twitter that all I really want is vim with TextMate's Command-T go-to-file functionality and some efficient visual tab/buffer navigation. Turns out MacVim + Janus, with just a few tweaks, is all that and more.

Installing Janus

Follow the installation instructions on the git page

@simeonwillbanks
simeonwillbanks / gem_make.out
Last active September 26, 2015 20:58
#commandline #mysql2 #gem $ sudo gem install mysql2 -- --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/simeon/.rbenv/versions/ree-1.8.7-2011.03/bin/ruby extconf.rb --with-mysql-dir=/usr/local --with-mysql-config=/usr/local/bin/mysql_config
checking for rb_thread_blocking_region()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
@simeonwillbanks
simeonwillbanks / bin
Created August 20, 2011 03:54
#commandline brew mysql symlinks
lrwxr-xr-x 1 simeon wheel 32 Aug 18 17:06 /usr/local/bin/mysql -> ../Cellar/mysql/5.5.14/bin/mysql
lrwxr-xr-x 1 simeon wheel 39 Aug 18 17:06 /usr/local/bin/mysql.server -> ../Cellar/mysql/5.5.14/bin/mysql.server
lrwxr-xr-x 1 simeon wheel 44 Aug 18 17:06 /usr/local/bin/mysql_client_test -> ../Cellar/mysql/5.5.14/bin/mysql_client_test
lrwxr-xr-x 1 simeon wheel 39 Aug 18 17:06 /usr/local/bin/mysql_config -> ../Cellar/mysql/5.5.14/bin/mysql_config
lrwxr-xr-x 1 simeon wheel 53 Aug 18 17:06 /usr/local/bin/mysql_convert_table_format -> ../Cellar/mysql/5.5.14/bin/mysql_convert_table_format
lrwxr-xr-x 1 simeon wheel 42 Aug 18 17:06 /usr/local/bin/mysql_find_rows -> ../Cellar/mysql/5.5.14/bin/mysql_find_rows
lrwxr-xr-x 1 simeon wheel 47 Aug 18 17:06 /usr/local/bin/mysql_fix_extensions -> ../Cellar/mysql/5.5.14/bin/mysql_fix_extensions
lrwxr-xr-x 1 simeon wheel 43 Aug 18 17:06 /usr/local/bin/mysql_install_db -> ../Cellar/mysql/5.5.14/bin/mysql_install_db
lrwxr-xr-x 1 simeon wheel 52 Aug 18 17: