Skip to content

Instantly share code, notes, and snippets.

View stefbowerman's full-sized avatar

Stefan Bowerman stefbowerman

View GitHub Profile
width = 200
height = 200
area = width * height
container = document.getElementById 'container'
canvas = document.createElement 'canvas'
canvas.width = width
canvas.height = height
canvas.style.display = 'block'
@stefbowerman
stefbowerman / ShoppingCart.coffee
Created July 7, 2014 22:15
Simple shopping cart class written in coffeescript
# Items have the following properties : ID (string), size (string), sizeDisplay (string), price (int)
class ShoppingCart
constructor: (@shipping = 5) ->
@items = []
_listItems: -> @items
addItem: (item) ->
@stefbowerman
stefbowerman / TickingClock.coffee
Last active August 29, 2015 14:03
Simple Coffeescript Clock
class Clock
constructor: (targetEl) ->
@$targetEl = $(targetEl)
@tickingInterval = null
startTicking: ->
@tick()
@tickingInterval = setInterval( =>
@tick()
@stefbowerman
stefbowerman / Violations-2012.csv
Created July 18, 2014 20:57
Code For America 2015 Interview question. Take the provided CSV, use your preferred language to parse it and display the data. Requested information was 1) the number of violations in each category, 2) the earliest violation date for each category and 3) the latest violation date for each category. jQuery is listed as a dependency but only for p…
violation_id inspection_id violation_category violation_date violation_date_closed violation_type
204851 261019 Garbage and Refuse 2012-01-03 00:00:00 2012-02-02 00:00:00 Refuse Accumulation
204852 261019 Unsanitary Conditions 2012-01-03 00:00:00 2012-02-02 00:00:00 Unsanitary conditions, not specified
204853 261023 Garbage and Refuse 2012-01-03 00:00:00 2012-01-17 00:00:00 Refuse Accumulation
204854 261023 Garbage and Refuse 2012-01-03 00:00:00 2012-01-17 00:00:00 Refuse Accumulation
204858 261029 Garbage and Refuse 2012-01-03 00:00:00 2012-03-12 00:00:00 Refuse Accumulation
204859 261029 Animals and Pests 2012-01-03 00:00:00 2012-03-12 00:00:00 Animals and Pests, not specified
207746 264687 Animals and Pests 2012-02-08 00:00:00 2012-04-02 00:00:00 Animals and Pests, not specified
205869 262387 Garbage and Refuse 2012-01-13 00:00:00 2012-01-17 00:00:00 Refuse Accumulation
207417 264347 Garbage and Refuse 2012-01-11 00:00:00 2012-01-13 00:00:00 Refuse Accumulation
@stefbowerman
stefbowerman / Chalkboard.scss
Created August 22, 2014 02:29
Make a chalkboard with html!
/*
*
* To build a chalkboard, use the following HTML structure
*
* <div class="chalkboard-frame">
* <div class="chalkboard">
* <div class="chalkboard-interior">
* <div class="chalkboard-content">
* <!-- Enter your content here -->
* </div>
@stefbowerman
stefbowerman / CLI_BS.bash
Last active October 19, 2015 22:57
Assorted bash commands to get me through life
# Copy a file from local host to remote host
##################################################
scp -i ~/.ssh/{key}.pem {local_file} {username}@{host}:{directory_path}
# i.e. scp -i ~/.ssh/elder-aws.pem ./my_file.php ubuntu@ec2-52-27-158-192.us-west-2.compute.amazonaws.com:/var/www/html/directory
# Copy a file from a remote host to local host
##################################################
@stefbowerman
stefbowerman / _magento_on_ec2.md
Last active October 7, 2015 17:50
How to set up a new Magento installation on AWS EC2

💖 Magento & AWS EC2 💖

This is a checklist and guideline to get you through the setup and of a magento (1.9.x) install on ec2. This guide is meant to be general, but was made while setting up Magento 1.9.1 on an EC2 instance running Ubuntu 14.04.2.

Setting up security groups

You'll need to make 2 different security groups, one for the EC2 instance and one for the RDS instance. Make sure to name them accordingly so you can remember which to apply to which instance.

EC2 Security Group

  • Go to the EC2 dashboard
  • Go to security groups and create a new security group
  • Inbound rules must include the following:
var Thing = function(){
var _this = this;
this.checkContext = function(){
console.group()
console.log('Checking context.....');
console.log('this', this); // Outputs - Thing
$(window).on('check-context', function(){
console.log('inside window listener callback without context binding');
@stefbowerman
stefbowerman / update_master_branch.md
Last active November 4, 2015 22:35
How to update master with development branch while keeping the commit history clean

First create an integration branch out of your development branch

git checkout -b myfeature-int

  • This guarantees that you won't spoil your development branch
  • This is especially valid for dev branches that are also remote, we should never rewrite the history of a shared branch

Then rebase that new branch onto master

git rebase -i master myfeature-int

  • Ideally you do an interactive rebase with the -i flag, so that you can squash, reorder, or drop commits
  • Having 3 commits for subsequently renaming a class is an ideal candidate for squashing
  • Don't hesitate to re-do it several times over. It's easier to, for example, first reorder some commits, make sure they can be re-applied in that order, then do a second rebase to squash'em.
// Option 1
$(body).on('click', function(){
console.log(this); // body
});
// Option 2
function onClick(){
console.log(this);
}