Skip to content

Instantly share code, notes, and snippets.

View austinbv's full-sized avatar
🎯
Focusing

Austin austinbv

🎯
Focusing
View GitHub Profile
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 }
@austinbv
austinbv / .rb
Created December 22, 2011 23:48
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
@austinbv
austinbv / ERROR
Created December 22, 2011 05:57 — forked from anonymous/ERROR
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:
class Model
def child
Child.where(:model_id => id)
end
def child_name
child.name
end
end
class Model
has_one :child
def children_names
child.name
end
end
class Model
has_one :child
# the solution to eager load
# should be 2 queries
posts = Post.find(:all, :include => :comments)
posts.each do |post|
post.comment
end
dropbox |
|
- rails_app |
|
- app
- config
@austinbv
austinbv / Deadlock.java
Created December 8, 2011 01:29 — forked from thelittlemango/Deadlock.java
Deadlock Simulation
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 {
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++) {
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