This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script merges all the repos we have into subfolders in a new repo | |
# | |
# Clones or copies a repository from either disc or remote repository. | |
cloppy() { | |
local dir=$1 | |
if [[ -z $2 ]]; then | |
local repo=$dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dotify(hash, k = []) | |
return {k.join('.') => hash} unless hash.is_a?(Hash) | |
hash.inject({}){ |h, v| h.merge! dotify(v[-1], k + [v[0]]) } | |
end | |
describe "dotify" do | |
let(:hash) { { foo: { bar: { baz: true } } } } | |
it "converts hash to dot notated keys" do | |
expect(dotify(hash)).to eq("foo.bar.baz" => true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I usually end up with something like below in my code | |
def fetch_something | |
current_something.coll_association.find_by some: 123, other: 'sasd' | |
end | |
# I want to test that the finder gets called with the right arguments | |
it "finds cool_association using the right arguments" do | |
expect(current_something).to receive_message_chain('cool_association.find_by'). | |
with(some: 123, other: 'sasd') { cool_association } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dscacheutil -flushcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON("/admin/widgets", function(data) { | |
$.each(data, function(index, object) { | |
var widget = object.table; | |
console.log('widget id:' + widget.id, + ', name' + widget.name); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
for X in `ps acx | grep -i $1 | awk {'print $1'}`; do | |
kill $X; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for gem in `gem list --no-version`; do | |
gem uninstall -aIx $gem | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
common: &default_settings | |
adapter: mysql2 | |
host: localhost | |
username: root | |
encoding: utf8 | |
reconnect: false | |
pool: 5 | |
development: | |
<<: *default_settings |