Skip to content

Instantly share code, notes, and snippets.

View tibbon's full-sized avatar

David Fisher tibbon

View GitHub Profile
@tibbon
tibbon / gist:6073142
Last active December 20, 2015 04:48
Objects and Prototype
// String literal, string primitive
// This is not an object
// This doesn't have any of its own functions
var schoolName = "General Assembly"
// When I call this, it temporarily makes a String Object around it.
// Slower. I'll talk about why in a second
var upperCaseSchoolName = schoolName.toUpperCase
/*
@tibbon
tibbon / gist:6065875
Created July 23, 2013 20:29
Javascript Scope
function calculateHeight(startPoint, endPoint) {
// This function has access to startPoint and endPoint. Nothing else does.
return Math.abs(startPoint - endPoint)
}
function calculateWidth(startWidth, endWidth) {
// Function arguments act as local. ie. startWidth here is local
// This function has access to startWidth and endWidth. Nothing else does.
// Does this have access to a, b, x, y? No
// Does this have access to q? No
@tibbon
tibbon / gist:5962843
Created July 10, 2013 01:39
Validating uniqueness at the DB/migration level
class AddUniquenessIndexToYears < ActiveRecord::Migration
def change
add_index :years, [:award_id, :book_id], :unique => true
end
end
@tibbon
tibbon / gist:5961328
Created July 9, 2013 21:11
July 9th Reading
@tibbon
tibbon / book.rb
Created July 9, 2013 19:25
Attr Accessible
class Book < ActiveRecord::Base
# Other stuff should go up here, the following is an example of attr_accessible to allow mass assignment
# Mass assignment is when you do something like Book.create(title: "1984")
attr_accessible :title
end
@tibbon
tibbon / gist:5959868
Created July 9, 2013 18:27
Join tables without IDs

These need to be backed up by a migration to create the assemblies_parts table. This table should be created without a primary key:

class CreateAssembliesPartsJoinTable < ActiveRecord::Migration
  def change
    create_table :assemblies_parts, id: false do |t|
      t.integer :assembly_id
      t.integer :part_id
    end
 end
@tibbon
tibbon / git
Created June 17, 2013 23:22 — forked from chyld/git
# ----------------------------------------------------------------- #
REFERENCES
# ----------------------------------------------------------------- #
http://ndpsoftware.com/git-cheatsheet.html
# ----------------------------------------------------------------- #
BASIC
# ----------------------------------------------------------------- #
@tibbon
tibbon / gist:5794257
Created June 17, 2013 02:08
Linux Bash Examples
Macbook Pro:bash_example tibbon$ ls
hello_world.rb lib
Macbook Pro:bash_example tibbon$ ls -al
total 0
drwxr-xr-x 4 tibbon staff 136 Jun 16 22:05 .
drwxr-xr-x 151 tibbon staff 5134 Jun 16 22:04 ..
-rw-r--r-- 1 tibbon staff 0 Jun 16 22:05 hello_world.rb
drwxr-xr-x 3 tibbon staff 102 Jun 16 22:05 lib
Macbook Pro:bash_example tibbon$ cd lib
Macbook Pro:lib tibbon$ ls
@tibbon
tibbon / gist:5695283
Last active December 18, 2015 00:18
Programming things I want to Learn- 2013 Edition
This should probably be a blog post, but if I do that then I want to make it readable to others.
Anyway, I want to get more awesome at the following things (which I already know a bit about each)
- C
- Haskell
- Go
- Python
- Javascript
- Postgres
@tibbon
tibbon / gist:5614100
Created May 20, 2013 18:13
Chef/Vagrant issue
Macbook Pro:chef-guide tibbon$ rake start
vagrant up
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["--version"]
Stderr: dyld: Library not loaded: /Applications/VirtualBox.app/Contents/MacOS/VBoxRT.dylib
Referenced from: /Applications/VirtualBox.app/Contents/MacOS/VBoxManage
Reason: no suitable image found. Did find: