Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
@miah
miah / gist:3876136
Created October 11, 2012 23:02
chef-server cookbook fail.
magical-unicorn:chef_server miahjohnson$ vagrant up
[chef_server] Importing base box 'opscode-ubuntu-12.04'...
[chef_server] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.
Guest Additions Version: 4.1.22
VirtualBox Version: 4.2.1
@zacstewart
zacstewart / anonymous_user.rb
Created October 2, 2012 17:35
Rails Soft Sign-Up
class AnonymousUser < User
attr_accessible *ACCESSIBLE_ATTRS, :type, :token, as: :registrant
def register(params)
params = params.merge(type: 'User', token: nil)
self.update_attributes(params, as: :registrant)
end
end
@terenceponce
terenceponce / instructions.md
Created September 26, 2012 08:25
Setting up Thinking-Sphinx on Mac OS X using Homebrew

Out of the box, Homebrew does a default installation on Sphinx:

$ brew install sphinx

However, if you're using MySQL, the thinking-sphinx gem won't work because it needs to use MySQL libraries.

If you managed to screw up the first time, uninstall sphinx first:

$ brew remove sphinx

@karmi
karmi / active_record_associations.rb
Created July 29, 2012 16:57
An example of elasticsearch & Tire setup for ActiveRecord associations
# An example of elasticsearch & Tire setup for ActiveRecord associations.
#
# A `Book has_many :chapters` scenario, with mapping and JSON serialization
# for indexing associated models.
#
# Demonstrates three important caveats as of now:
#
# 1. You you have to use `touch: true` in the `belongs_to` declaration,
# to automatically notify the parent model about the update.
#
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 15, 2025 05:11
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@bsodmike
bsodmike / Gemfile
Created May 23, 2012 11:14
Resque + Bluepill Nirvana
gem 'resque-ensure-connected'
@bsodmike
bsodmike / fast-one.rb
Created May 11, 2012 12:09 — forked from jeremyf/fast-one.rb
A command line tool to help with testing pull requests.
#!/usr/bin/env ruby
# Before you use this:
# git clone git://github.com/some-other-user/their-repo
# This assumes that origin is the repo that you are merging into!
require 'rubygems'
gem 'rest-client'
gem 'crack'
require 'rest-client'
@sj26
sj26 / 0-readme.md
Created May 5, 2012 05:39 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p194 with patches for boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

@gnepud
gnepud / test_helper.rb
Created April 6, 2012 08:57 — forked from sethbro/test_helper.rb
MiniTest::Spec with Rails 3.2 setup
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/pride'
require 'capybara/rails'
class MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
  1. I find a mistake in the book or somebody else points one out using the review system's notes.
  2. I fix the mistake in the ERB/XML version of the book.
  3. The ERB/XML version is then automatically converted into an XML document via a running Guard process.
  4. I commit both files to the Git repository for the book, and then push these to GitHub
  5. GitHub tells the review tool that a push has occurred, and sends through a push notification.
  6. The review tool receives the notification and stores a job in Resque to parse the book.
  7. A resque worker runs the job, detecting which files have changed and then updates just those chapters.
  8. For each chapter, each element is processed individually using an XSLT file and stored in a MongoDB database as HTML (I know, right?)
  9. When a user requests a chapter, this page is then read from the database and then cached back to Redis.
  10. Every time a chapter is updated, be it by the automated process or by a user putting a note on the book, the cache is reset.