This file contains hidden or 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
# 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 |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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 file in **/*.rb; do | |
[ -e "$file" ] || continue | |
if [[ -n "$(tail -c 1 <"$file")" ]]; then | |
echo >> "$file" | |
fi; | |
done |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |