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 GameOfLife | |
attr_reader :width, :height, :cells | |
def initialize(width = 5, height = 5, seed = 5) | |
raise ArgumentError.new "Seed must be < than width x height!" if seed >= width * height | |
@width, @height = width, height | |
@cells = Array.new(width * height, 0) | |
@cells[rand(cells.size)] = 1 while cells.select{|c| c == 1}.size < seed | |
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
source 'http://rubygems.org' | |
gem 'rails', '3.0.0.rc2' | |
# Bundle edge Rails instead: | |
#gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => "3-0-stable" | |
gem 'mysql2' | |
gem 'awesome_print', :require => 'ap' | |
gem 'rails3-generators', "0.12.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
/usr/lib/ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize': not in gzip format (Zlib::GzipFile::Error) | |
from /usr/lib/ruby/1.8/rubygems/package/tar_input.rb:49:in `new' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_reader.rb:64:in `each' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_reader.rb:55:in `loop' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_reader.rb:55:in `each' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_input.rb:32:in `initialize' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_input.rb:17:in `new' | |
from /usr/lib/ruby/1.8/rubygems/package/tar_input.rb:17:in `open' | |
from /usr/lib/ruby/1.8/rubygems/package.rb:58:in `open' |
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
$ gem install mysql2 --debug | |
Exception `NameError' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:164 - uninitialized constant Gem::Commands::InstallCommand | |
Exception `NoMethodError' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/rational.rb:78 - undefined method `gcd' for Rational(1, 2):Rational | |
Exception `Gem::LoadError' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems.rb:779 - Could not find RubyGem test-unit (>= 0) | |
Exception `Gem::LoadError' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems.rb:779 - Could not find RubyGem sources (> 0.0.1) | |
Exception `IOError' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/format.rb:50 - closed stream | |
Exception `Errno::EEXIST' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/fileutils.rb:243 - File exists - /home/fpauser/.rvm/gems/ruby-1.8.7-p302 | |
Exception `Errno::EEXIST' at /home/fpauser/.rvm/rubies/ruby-1.8.7-p302/lib |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
[ -z "$PS1" ] && return | |
# don't put duplicate lines in the history. See bash(1) for more options | |
# ... or force ignoredups and ignorespace | |
HISTCONTROL=ignoredups:ignorespace |
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 ruby | |
## Modified from Gem Session's Dumple, available at: | |
## http://gem-session.com/2010/07/dumping-database-from-within-rails-project | |
fail_gently = ARGV.include?("--fail-gently") | |
gzip = ARGV.include?("--compress") | |
if ARGV.include?("-i") | |
puts "*******************************************************" |
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
// remove crappy contents from news.google.de | |
$("div.source, span.source").filter(function() { return /(BILD|WELT ONLINE)/.test( $(this).text() ) }).parent().fadeOut(); | |
$("h2.title > a").filter(function() { return /.*(welt.de|bild.de).*/.test( $(this).attr('href') ) } ).parents("div.story").fadeOut(); |
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 a working sudo in a non-interactive ssh session: | |
1. Copy askpass to $HOME/bin/askpass & make it executeable (chmod +x $HOME/bin/askpass) | |
2. Change your deploy.rb to setup the SUDO_ASKPASS environment variable (see man sudo) | |
Credits: http://serverfault.com/questions/307366/error-deploying-app-with-vlad-running-a-sudo-command-to-ubuntu-server |
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 CreateViewTest < ActiveRecord::Migration | |
def up | |
create_view_or_table :view_test do | |
view_column :select => "#{source_db}.dbo.Config.value", :as => :config_value, :type => :integer | |
view_sql "FROM #{source_db}.dbo.Config" | |
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
<!doctype html> | |
<html><head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> | |
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> | |
<script type='text/javascript' src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script> | |
<script type='text/javascript' src="http://cloud.github.com/downloads/emberjs/ember.js/ember-latest.js"></script> | |
</head><body> | |
<script type="text/x-handlebars" data-template-name="application"> | |
<h1>Application</h1> | |
<a href="#/dashboard">Dashboard</a> |
OlderNewer