Skip to content

Instantly share code, notes, and snippets.

@grant-roy
grant-roy / active-record.md
Last active August 29, 2015 14:14
Working with Active Record

##Active Record

###ORM

Object-Relational-Mapper

It's critical to understand exactly what an ORM is, and by turn then gain an understanding of ActiveRecord and the things it can do for us. Imagine we have the following structure in our database:

//A Table for a Band
@grant-roy
grant-roy / ar-walkthrough.md
Last active September 3, 2015 18:42
AR walkthough exercises

###AR Exercise walk-through

#create a new rails project named 'ar'
$ rails new ar -T -d postgresql

#run bundle
$ bundle

#create Band model
@grant-roy
grant-roy / js-unit-test.md
Last active August 29, 2015 14:07
Javascript Testing Part 1

####Javascript Testing Part-1

####Why do we test code...in an automated fashion.

Mark Ethan Trostler ( Google )..from Testable Javascript :

You have to write unit tests, so quit messing around and write some.

From the angular docs ( Many people at Google ):

JavaScript is a dynamically typed language which comes with great power of expression, but it also comes with almost no help from the compiler. For this reason we feel very strongly that any code written in JavaScript needs to come with a strong set of tests. We have built many features into Angular which makes testing your Angular applications easy. So there is no excuse for not testing.

###How to think like a progammer

####First

Lets dispense with the idea of a 'programming genius'. A good talk on the topic is The Myth of the Genius Programmer

Programming well is about methodology.....not sparks of brillant insight( though these occasionally occur )

Before we actually formalize our methodology, lets learn the most important single thing to be a great Programmer:

####What is a hash?

A semi-famous joke in computer science goes like this:

There are only two hard things is computer science: naming things, cache invalidation, and off by one errors.

In terms of the first diffuculty, naming things, let's think about Hash. What does that bring to mind....breakfast potatoes?..something rockstars in the 1960's smoked in Morrocco?...Twitter hash tags?

Hash is actually short for HashMap...still not very descriptive, Lets see if we can do a bit better.

@grant-roy
grant-roy / update-jekyll
Last active March 28, 2024 10:45
Bash script to poll Github and rebuild and restart a jekyll site
#!/bin/sh
#This is a simple bash script that will poll github for changes to your repo,
#if found pull them down, and then rebuild and restart a Jekyll site running
#in Nginx. Note, we cannot use cron to schedule a job every 5 seconds, so we create
#a script that executes an infinite loop that sleeps every 5 seconds
#We run the script with nohup so it executes as a background process: $nohup ./update-jekyll
while true
do