Skip to content

Instantly share code, notes, and snippets.

huiming@mars:natives (master=)$ time be rake
/Users/huiming/.rubies/ruby-1.9.3-p429/bin/ruby -S rspec spec/natives/apps/detect_spec.rb spec/natives/apps/list_spec.rb spec/natives/catalog/loader_spec.rb spec/natives/catalog/merger_spec.rb spec/natives/catalog/normalizer_spec.rb spec/natives/catalog/selector_spec.rb spec/natives/catalog/validator_spec.rb spec/natives/catalog_spec.rb spec/natives/gemfile_viewer_spec.rb spec/natives/host_detection/package_provider_spec.rb spec/natives/host_detection/platform_spec.rb spec/natives/host_detection_spec.rb
...........................................................
Finished in 12.5 seconds
59 examples, 0 failures
real 0m19.849s
user 0m14.280s
sys 0m1.425s
@teohm
teohm / es.sh
Created November 23, 2013 10:56
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
sudo dpkg -i elasticsearch-0.90.7.deb
#!/bin/bash
_now=$(date +"%Y-%m-%d-%H%M%S")
_file="/u/backups/foo/pg-$_now.dump"
sudo -u postgres pg_dump -Fc foo_production > "$_file"
@teohm
teohm / gist:7781729
Created December 4, 2013 03:08 — forked from afeld/gist:5704079

TODO: make gem for this

This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.

Bower

  1. Set the install directory for Bower components:

// .bowerrc

#!/bin/bash -e
export RBENV_ROOT=/usr/local/rbenv
export PATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/bin:"$PATH"
APP="<%= @options[:app].application.name %>"
APP_PATH="<%= @options[:app].path %>"
RAILS_ENV="<%= @options[:rails_env] %>"
UNICORN_CONFIG="/etc/unicorn/${APP}.rb"
CUR_PID_FILE="${APP_PATH}/shared/pids/unicorn.pid"
@teohm
teohm / spec_helper.rb
Created December 10, 2013 09:41
rspec
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
module FixtureSupport
@teohm
teohm / _top3things.md
Last active December 31, 2015 04:58
my top 3 things

Top 3 Things \(o_o)/


1. workstation setup script (base cli, mac)

2. top3things app

3. Chef Fundamentals series


  • Chef Fundamentals series
  • Logstash book

I recently got PATCH mostly working with Backbone and Rails 3, here's what I needed to do.

Sticking Points:

  1. [Rails] JSON Patch gem needs updated.
  2. [Rails] Routing verb for patch missing - I believe this is fixed in Rails 4, haven't investigated.
  3. [Rails] Need to parse the 'application/json-patch+json' content type in sort of a crazy way
  4. [Rails] Building a patch and applying it to an activerecord model is kind of a pain, ideally we'd have a ActiveModel#apply_patch(json_patch)
  5. [Backbone] Building a patch from a set of attributes is tricky - I've done the bare minimum using a loop over a hash to build add operations, which should probably cover a good chunk of cases for backbone. (I imagine most people aren't going to need the json-patch support for moving, copying or deleting keys generally.)

rAndom ruBy tiPs >>--(o_0)-->