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
| ruby-1.9.2-p180 :010 >1000000.times { x << (Random.rand()*100000000000000000000000000000000000).to_i } | |
| ruby-1.9.2-p180 :015 > Benchmark.realtime { x.sort } | |
| => 2.3872387409210205 | |
| ruby-1.9.2-p180 :028 > 1000000.times { x << (Random.rand()) } | |
| => 1000000 | |
| ruby-1.9.2-p180 :029 > x.first | |
| => 0.5471985207954021 | |
| ruby-1.9.2-p180 :030 > Benchmark.realtime { x.sort.reverse } |
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
| x = ['2.5', '3.0', '3.0-', '3.5', '3.5-', '4.0', '4.0-', '4.5', '4.5-', '5.0', '5.5', '6.0', '6.0-'] | |
| x.sort_by do |y| | |
| case y | |
| when '2.5' | |
| 1 | |
| when '3.0-' | |
| 2 | |
| when '3.0' | |
| 3 |
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
| NoMethodError in Devices#locations | |
| Showing /home/russellpruitt/projects/inventory/app/views/devices/locations.html.erb where line #3 raised: | |
| undefined method `device' for #<ActiveRecord::Relation:0xa6d4fd4> | |
| Extracted source (around line #3): | |
| 1: <h1>Devices for: <%= @location.location_name %></h1> | |
| 2: |
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 Model | |
| def child | |
| Child.where(:model_id => id) | |
| end | |
| def child_name | |
| child.name | |
| 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 Model | |
| has_one :child | |
| def children_names | |
| child.name | |
| end | |
| end | |
| class Model | |
| has_one :child |
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 solution to eager load | |
| # should be 2 queries | |
| posts = Post.find(:all, :include => :comments) | |
| posts.each do |post| | |
| post.comment | |
| 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
| dropbox | | |
| | | |
| - rails_app | | |
| | | |
| - app | |
| - config | |
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
| import java.util.*; | |
| //------------------------------------------------------------------ | |
| // Program by: Sam Fader and Bell Lopez | |
| // The purpose of this program is to determine if processes are | |
| // deadlocked or not. | |
| // We pledge that this work is ours. | |
| //------------------------------------------------------------------- | |
| public class Deadlock { |
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
| import java.util.Scanner; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner in = new Scanner(System.in); | |
| System.out.println("Please give me a number"); | |
| int num = in.nextInt(); | |
| Person[] people = new Person[num]; | |
| for (int x = 0; x < people.length; x++) { |
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
| call pathogen#infect() | |
| runtime! autoload/pathogen.vim | |
| if exists('g:loaded_pathogen') | |
| call pathogen#runtime_prepend_subdirectories(expand('~/.vimbundles')) | |
| endif | |
| syntax on | |
| filetype plugin indent on | |
| colorscheme vividchalk |