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
$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 / 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 / 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() {
}
};
}
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;
# 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
@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