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
The socket is in a weird spot on Ubuntu - add this symbolic link to put it where everyone expects: | |
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock |
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
rvm pkg install openssl | |
rvm remove 1.9.2 | |
rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr |
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
var calculate = function ($) { | |
var revenue=$('#revenue').val(); | |
var margin = 0.3; | |
var profit1=(revenue * margin) - (revenue * 0.15); | |
var profit2=(revenue * margin) - (revenue * 0.05 + 100); | |
var profit3=(revenue * margin) - (revenue * 0.01 + 250); | |
$('#profit1').text(profit1); | |
$('#fee1').text(revenue * 0.15); | |
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 streak | |
return "-" if @played_games.empty? | |
games=@played_games | |
streak=0 | |
game=games.pop | |
last_result=game.result_type(@team.id) | |
until game.nil? || game.result_type(@team.id)!=last_result do | |
game=games.pop | |
streak+=1 |
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
# given a model (SomeModel), generate seeds.rb file from existing data in the database | |
elements=SomeModel.all.collect do |m| | |
"#{m.class.to_s}.create(#{m.attributes.select{|k, v| !["id", "created_at", "updated_at"].include?(k)}.collect{ |k, v| ":#{k} => '#{v.to_s.gsub("'", "\\\\'")}'" }.join(', ')})" | |
end | |
File.open('seeds.rb', 'w') {|f| elements.each{|element| f.puts(element)} } |
NewerOlder