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
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|
$snapins = Get-PSSnapin -Registered
$snapins | Add-PSSnapin
Get-Module -ListAvailable | Import-Module
Get-PSSnapin | Format-Table -autosize PSVersion, Name
Get-Module | Format-Table -autosize ModuleType, Name
function ff ([string] $glob) { get-childitem -recurse -include $glob }
(function() {
var gs = document.createElement('script'), gsc = document.createElement('div'), interval;
gs.type = 'text/javascript'; gs.async = true; gsc.id = 'getsatisfaction';
gs.src = document.location.protocol + '//s3.amazonaws.com/getsatisfaction.com/javascripts/feedback-v2.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(gs);
(document.getElementsByTagName('body')[0]).appendChild(gsc);
interval = setInterval(function() {
if (window.GSFN !== undefined) {
new GSFN.feedback_widget({
@mhenrixon
mhenrixon / syntax_highlighting.py
Created January 15, 2012 08:39 — forked from davelnewton/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@mhenrixon
mhenrixon / es.sh
Created January 17, 2012 10:56 — forked from jmikola/es.sh
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get install unzip
sudo apt-get install python-software-properties -y
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
@mhenrixon
mhenrixon / q_export_and_wait.pas
Created April 19, 2012 07:49
How to manually wait for a Jeeves CrystalExportToFile to complete.
// The last parameter is wait and that doesn't work in Windows 7 for some reason. It don't get the completion notification so we wait until the file is ready
CrystalExportToFile(sCrystalTemplate,sFile,sTempDir, sCondStr, false, false,'',false);
while (fileexists(sTempDir+'\'+sFile,true)<>0) do begin
sleep(1000);
end;
@mhenrixon
mhenrixon / progressbar.pas
Created April 19, 2012 07:58
Jeeves JML progressbar
oPrgBar := Application.CreateProgressDlg('Some message to display',5);
If oPrgBar <> '' then begin
//Display progress bar
oPrgBar.SetStyle(0); //0 = straight, 1 = Circular
oPrgBar.SetCancelButton(false); //Disable cancel
oPrgBar.show;
oPrgBar.IncCount; //Display incremention
sleep(1000);
oPrgBar.IncCount; //Display incremention
sleep(1000);
@mhenrixon
mhenrixon / bootstrap_ruby.sh
Created July 16, 2012 07:16 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap ruby 1.9.3
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
make install
@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.

@mhenrixon
mhenrixon / exit_code_patch.rb
Created August 16, 2012 08:35
Monkey patch to make ruby exit codes work with continuous integration
# Monkey Patch ruby because of a bug introduced in ruby versions greater than 1.9.2
# For some reason the exit code is all wrong in later version of ruby and even though
# the issue was closed as sorted it's still broken in ruby version 1.9.3-p194.
# (see http://redmine.ruby-lang.org/issues/5218 for more information)
# Put this in spec_helper.rb or test_helper.rb so that it only affects specs and the CI server.
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
module Kernel
alias :__at_exit :at_exit
def at_exit(&block)
__at_exit do