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 / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# Public: Stubs partial search
# Examples =>
# stub_partial_search(:node, 'name:web*').and_return([{ 'fqdn' => 'web01.example.com' }])
#
def stub_partial_search(type, query)
allow(Chef).to receive(:partial_search).and_call_original
expect(Chef).to receive(:partial_search).with(type, query, any_args)
end

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@mhenrixon
mhenrixon / circle.yml
Last active August 29, 2015 14:23 — forked from jwaldrip/circle.yml
machine:
services:
- 'postgresql'
- 'redis'
environment:
REDIS_URL: 'redis://localhost:6379/0'
dependencies:
pre:
- 'git config user.email deploy+$CIRCLE_USERNAME@brandfolder.com'
- 'git config user.name $CIRCLE_USERNAME'
(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 / 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;