Skip to content

Instantly share code, notes, and snippets.

View mhenrixon's full-sized avatar
🐢
I may be slow to respond.

Mikael Henriksson mhenrixon

🐢
I may be slow to respond.
View GitHub Profile
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p327
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
require 'json'
class Saltsider
RANKS = ['Script Kid', 'n00b', 'Programmer', 'Rock Star', 'l33t',
'Saltsider']
P_ATTRIBUTES = [:name, :email, :phone]
S_ATTRIBUTES = [:html, :css, :javascript, :ruby, :ruby_on_rails]
def initialize(attributes = {})
# Usage: rake name:task app_name
task PROD = "appname" # "task" here stubs to prevent rake errors with commandline
task STAGING = "appname-staging"
APP = ARGV[1] || PROD # default app
puts "=== APP #{APP} ==="
namespace :deploy do

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git
  • Copy/paste from the command line:
sudo apt-get install xclip
@mhenrixon
mhenrixon / edit_post_spec.rb
Created December 3, 2012 11:19 — forked from weilu/edit_post_spec.rb
Turn off transactional fixtures only for Capybara javascript specs
# requests/edit_post_spec.rb
require 'spec_helper'
feature 'editing a post', js: true do
let(:post) { create :post }
let(:user) { post.creator }
before { sign_in user }
@mhenrixon
mhenrixon / migrate_s3.rake
Created December 1, 2012 14:01
rake task to migrate paperclip attachments to Amazon S3
namespace :attachments do
task :migrate_to_s3 => :environment do
require 'aws/s3'
# Load credentials
s3_options = YAML.load_file(File.join(Rails.root, 'config/s3.yml')).symbolize_keys
bucket = s3_options[:bucket_name]
# Establish S3 connection
# Scenario för att välja produkt
# Resurser som behövs är:
# @card_products
# Scenario för produkten 'Period buss'
# Resurser som behövs är:
# @product
class AddCountTriggers < ActiveRecord::Migration
def up
execute %q{
CREATE OR REPLACE FUNCTION update_task_counters (taskid integer)
RETURNS void AS $$
BEGIN
update tasks set
users_count = coalesce((select count(9) from taskships where task_id = taskid), 0)
where id = taskid;
END;
@mhenrixon
mhenrixon / console.js
Created October 2, 2012 14:37 — forked from dagda1/console.js
console.js
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {
log: function() {
}
};
}
@mhenrixon
mhenrixon / configuring tire for bonsai.md
Created July 17, 2012 20:17 — forked from nz/configuring tire for bonsai.md
Configuring Tire to work with Bonsai

Configuring Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire', '~> 0.4.1'

Bonsai provisions one ElasticSearch index per application. Tire, however, assumes that each model is using its own index.

Currently the best way to work around this is to set the Tire.configuration.url and the model's index_name manually.