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
class Device | |
# ... | |
def friendly_name | |
"#{self.customer.device_name_prefix} #{self.device_number}" | |
end | |
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
class Device | |
validates_uniqueness_of :device_number, :scope => :customer_id | |
after_create: assign_device_number | |
def assign_device_number | |
begin | |
device_number = self.customer.devices.map(&:device_number).compact.max) || 0 + 1 | |
save! | |
rescue Whatever gets thrown for validation error |
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 i in $(find db/migrate |grep mondrian |cut -d '/' -f 3 | cut -d '_' -f 1 ) | |
do | |
rake db:migrate:down VERSION=$i | |
rake db:migrate:up VERSION=$i | |
done | |
rake mondrian:init |
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
# Wrong! | |
# If foo is valid but bar is not, foo is still saved. | |
# This breaks the transactional nature | |
# | |
def create | |
Foo.transaction do | |
@foo = Foo.create(params[:foo]) | |
@bar = Bar.create(params[:bar]) | |
if @foo.save and @bar.save | |
redirect_to some_url |
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
[beaker:~/dev/mastermind] jzellman> git pull | |
From [email protected]:frogmetrics/mastermind | |
b27a181..62304b8 master -> origin/master | |
Already up-to-date. | |
[beaker:~/dev/mastermind] jzellman> git status | |
# On branch master | |
nothing to commit (working directory clean) | |
[beaker:~/dev/mastermind] jzellman> git pull | |
From [email protected]:frogmetrics/mastermind | |
+ 62304b8...b27a181 HEAD -> origin/HEAD (forced update) |
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
[beaker:~/dev/mastermind] jzellman> git fetch origin | |
git statusFrom [email protected]:frogmetrics/mastermind | |
b27a181..62304b8 master -> origin/master | |
[beaker:~/dev/mastermind] jzellman> git status | |
# On branch master | |
nothing to commit (working directory clean) | |
[beaker:~/dev/mastermind] jzellman> git pull | |
From [email protected]:frogmetrics/mastermind | |
+ 62304b8...b27a181 HEAD -> origin/HEAD (forced update) | |
Already up-to-date. |
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
[beaker:~/dev/mastermind] jzellman> git status | |
# On branch master | |
# Your branch is ahead of 'origin/master' by 322 commits. | |
# | |
nothing to commit (working directory clean) | |
[beaker:~/dev/mastermind] jzellman> git push origin master | |
git Everything up-to-date | |
[beaker:~/dev/mastermind] jzellman> git status | |
# On branch master | |
nothing to commit (working directory clean) |
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
starting vacuum...end. | |
transaction type: TPC-B (sort of) | |
scaling factor: 50 | |
number of clients: 25 | |
number of transactions per client: 100000 | |
number of transactions actually processed: 2500000/2500000 | |
tps = 319.300264 (including connections establishing) | |
tps = 319.306314 (excluding connections establishing) | |
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 current_brand | |
@_cached_brand ||= current_user.nil? ? look_up_from_reseller : | |
current_user.company.reseller.brand | |
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
#! /usr/bin/env python | |
# Reads in a file from stdin and converts its encoding from 8859 to utf-8 | |
# Writes to stdout and lines that fail to stderr | |
# Example usage ./convert.py < in.txt 1> out.txt 2> errors.txt | |
import sys | |
for line_number, line in enumerate(sys.stdin.readlines()): | |
try: | |
sys.stdout.write(unicode(line, "8859").encode("utf-8")) | |
except UnicodeDecodeError as e: |
OlderNewer