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 / tUnit2Rspec
Created November 26, 2020 21:29 — forked from yannis/tUnit2Rspec
Test::Unit to Rspec conversion ruby script
require "highline/import"
from_path = ask "Enter path for file to convert: "
to_path = ask "Enter the path where to save the spec file: "
unless File.exists? from_path
puts "Sorry this file doesn't exist!: #{from_path}"
puts "Please try again"
return
end
t_unit = File.read(from_path).to_s
@mhenrixon
mhenrixon / facebook_registration.rb
Created July 15, 2018 14:03 — forked from nicalpi/facebook_registration.rb
Testing Omniauth with Devise, Rspec and Capybara
background do
set_omniauth()
click_link_or_button 'Sign up with Facebook'
end
@mhenrixon
mhenrixon / docker-compose.yml
Created March 23, 2017 10:33 — forked from mdub/docker-compose.yml
How to share a /usr/local/bundle cache between Ruby build jobs
version: "2"
services:
dev:
image: ruby:2.3
volumes:
- .:/project
- ruby2.3-bundle-cache:/usr/local/bundle
working_dir: /project
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@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'

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# 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
@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
Update server
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo reboot
Enable Swedish locale and utf-8
sudo locale-gen sv_SE.UTF-8
sudo dpkg-reconfigure locales
Open sudo vim /etc/environment and add the folowing lines
# Example usage:
require 'active_record/nonpersisted_attribute_methods'
class Node < ActiveRecord::Base
include ActiveRecord::NonPersistedAttributeMethods
define_nonpersisted_attribute_methods [:bar]
# Example of using with ancestry and getting :parent to show up in changes hash.
has_ancestry
define_nonpersisted_attribute_methods [:parent]