Skip to content

Instantly share code, notes, and snippets.

View johnsome's full-sized avatar

Mark Johnson johnsome

View GitHub Profile
@johnsome
johnsome / INSTALL
Created September 1, 2011 11:26 — forked from mat/INSTALL
Turn an Ubuntu 10.04 server into a StatsD/Graphite server
TODO:
- edit /opt/statsd/local.js
- correct the graphite host to localhost
- if desired, put 'debug: true' in there
- make the box accessible via the hostname 'graphite'
- patch graphite, like described in https://answers.launchpad.net/graphite/+question/152851
@johnsome
johnsome / gist:1054688
Created June 29, 2011 19:27 — forked from wayneeseguin/gist:296055
install ruby 1.9.2 and Rails 3.1 RC
This example shows how to setup an environment running Rails 3 under 1.9.2 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2
# Switch to 1.9.2-head and gemset rails31rc, create if it doesn't exist.
∴ rvm --create use 1.9.2@rails31rc
@johnsome
johnsome / nokogiri
Created April 19, 2011 17:36 — forked from fabioyamate/nokogiri
nokogiri installation from libxml2 and libxslt mac osx snow leopard
http://nokogiri.org/tutorials/installing_nokogiri.html#mac_os_x
# using rvm with ruby-1.8.7-tv1_8_7_174
# latest version 2.7.7 2010-06-17
brew install libxml2
brew link libxml2 (FAILS) - so have to include below
# installing libxslt from source code
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz
running OSX 10.5.8
same error in ruby 1.9.2
mj:~ mark$ gem install ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
/Users/mark/.rvm/rubies/ruby-1.8.7-p302/bin/ruby extconf.rb
@johnsome
johnsome / gist:873699
Created March 17, 2011 01:34
ruby version date parsing differences and options
Key issue - format of entered dates:
date is displayed like: 31/3/2011
date is input like: 31-3-2011
This is works correctly in ruby 1.8 and 1.9
ruby-1.8.7-p302 > Time.parse '31-3-2011' # => Thu Mar 31 00:00:00 -1000 2011
ruby-1.9.2-p0 > Time.parse('31-3-2011') # => 2011-03-31 00:00:00 -1000
Changes in parsing dates for ruby 1.9:
* no longer has difference in parsing dates with dash or forward slash - they are always in euro format
@johnsome
johnsome / ruby time parsing
Created March 16, 2011 23:57
Time.parse differences between ruby 1.8 and 1.9
Time.parse('3-31-2011')
Time.parse('31-3-2011')
Time.parse('3/31/2011')
Time.parse('31/3/2011')
ruby-1.8.7-p302 > Time.parse('3-31-2011')
ArgumentError: argument out of range
from /Users/mark/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/time.rb:184:in `local'
from /Users/mark/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/time.rb:184:in `make_time'
@johnsome
johnsome / unchecked check box form submit in rails with jquery
Created January 6, 2011 21:36
use jquery to insert hidden checkbox for unchecked check boxes
The rails check_box form helper inserts a hidden checkbox to handle unchecked check boxes. This doesn't work when the check box is within an array-like parameter - i.e. project[invoice_attributes][blah].
So - below will append a hidden form field with a value - so it can be handled in your controller or model etc.
for:
<%= check_box_tag("instance[data][blah]") %>
jquery:
$("#instance_form").submit(function() {
// insert hidden checkbox with value 0 - so unchecked checkboxes submit a value
@johnsome
johnsome / gist:714397
Created November 24, 2010 20:56
ts - classloading issue?: undefined method `<<' for nil:NilClass
mj:fluxx_shakti mark$ DEV_LOCAL=1 rake ts:rebuild RAILS_ENV=fastdev --trace
(in /Users/mark/work/fluxx/s1/fluxx_shakti)
"Installing dependent fluxx gems to point to local paths. Be sure you install fluxx_engine, fluxx_crm and fluxx_grant in the same directory as the reference implementation."
"ESH: loading fluxx_engine"
"ESH: loading fluxx_crm"
"ESH: loading fluxx_grant"
** Invoke ts:rebuild (first_time)
** Invoke thinking_sphinx:rebuild (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
mj:~/work/mm/github/mm mark$ git push origin master
Counting objects: 9, done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 946 bytes, done.
Total 7 (delta 2), reused 0 (delta 0)
To git@github.com:johnsome/mm.git
07ee404..d2a36a6 master -> master
mj:~/work/mm/github/mm mark$ git push heroku
Counting objects: 12, done.
Compressing objects: 100% (10/10), done.
# rails testapp -m http://gist.github.com/314722.txt
file 'Gemfile', <<-CODE
source 'http://gemcutter.org'
gem "rails", :git => "git://github.com/rails/rails.git"
gem "sqlite3-ruby", :require => "sqlite3"
group :test do
gem "rspec-rails", ">= 2.0.0.a9"
end