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 | |
# check if parameter is passed | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <command>" | |
exit 1 | |
fi | |
# set the delay time (in seconds) | |
DELAY_TIME=25 |
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
# A probably flawed benchmark. Interested in your 2.6.3 vs TruffleRuby vs 3.0 times though :) | |
# Usage: open irb. paste in the below function. | |
def press | |
puts "Ruby version: #{RUBY_VERSION}, patchlevel: #{RUBY_PATCHLEVEL}, platform: #{RUBY_PLATFORM}, release date: #{RUBY_RELEASE_DATE}" | |
count=0 | |
start = Time.now | |
(1..10000).each { |value| count=count+value }; puts count | |
finish = Time.now | |
(finish - start) |
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
git remote add github [EMAIL PROTECTED]:myaccount/myapp.git | |
git remote add heroku [EMAIL PROTECTED]:myapp.git | |
Then you can do “git push heroku” and “git push github”, or pull, or | |
From: http://blog.mindtonic.net/using-github-and-heroku-together |
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
class Car | |
attr_accessor driving_genome | |
#Car has_many driving_methods | |
#Car has_many driving_evaluation_methods | |
#Car has_many detection_methods | |
def initiliaze(param) | |
@driving_genome = param.to_a | |
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
rails g model user name:string | |
rails g model favorite name:string design_id:integer user_id:integer | |
rails g model design name:string | |
class User | |
has_many: favourites | |
end | |
class Favorite |
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
grails create-app Creates a Grails application for the given name | |
grails create-domain-class Creates a new domain class | |
grails generate-all Generates a CRUD interface (controller + views) for a domain class | |
grails install-plugin Installs a plug-in for the given URL or name and version | |
grails create-controller Creates a new controller | |
grails interactive Starts Grails CLI (script runner) in interactive mode. | |
Keeps the JVM running between grails commands for faster script execution. | |
grails console Load the Grails interactive Swing console | |
grails run-app grails [environment]* run-app - Runs a Grails application |
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
// Ok. What am I trying to do? | |
// =========================== | |
// Extract 3 data values from the li elements in a ul list, | |
// that are easily identified by classes on the target page. | |
// Not rocket science. | |
// Tool: Aartoo. Client Side Javascript. Looks evolved. | |
// Simple bookmarket run from the extraction page, |
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
class Fixnum | |
def ordinalize | |
if (11..13).include?(self % 100) | |
"#{self}th" | |
else | |
case self % 10 | |
when 1; "#{self}st" | |
when 2; "#{self}nd" | |
when 3; "#{self}rd" | |
else "#{self}th" |
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 running in the console | |
require 'factory_girl' | |
models = [] | |
factories = [] | |
#otherwise this list isn't going to contain all models. | |
Rails.application.eager_load! | |
ActiveRecord::Base.descendants.each do |model| |
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
FactoryGirl.factories.each{ |fac| puts fac.name.capitalize unless fac.name.to_s.include? "_" };nil |
NewerOlder