Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@carolineartz
carolineartz / closures_ruby-PaulCantrell.rb
Created December 21, 2014 20:07
closures in ruby Paul Cantrell
# CLOSURES IN RUBY Paul Cantrell https://innig.net
# Email: username "cantrell", domain name "pobox.com"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
#
@carolineartz
carolineartz / bakery_num.rb
Last active August 29, 2015 14:11
Tutoring/GPS resource for refactoring bakery challenge. A possible solution (advanced)
#clerly there is way too much going on for a single method, but in an effort to keep with the challenge guidelines, here it stands
TREAT_SERVINGS = {"pie" => 8, "cake" => 6, "cookie" => 1} #making this a constant, in order from most servings to least (that is important)
def bakery_num(servings, favorite_food)
raise ArgumentError.new("You can't make that food") unless TREAT_SERVINGS.key?(favorite_food)
#instead of initializing them individually, we cna put it into a hash and easily associate with the servings hash
order_quantity = {"pie" => 0, "cake" => 0, "cookie" => 0}
fave_food_servings = TREAT_SERVINGS[favorite_food]
@carolineartz
carolineartz / student-feedback-notes.md
Last active August 29, 2015 14:10
resource for GPS- function expression vs declaration for JS challenge--a

Both declarations and expression declare a variable and put the function into it. The difference lies in how the browser parses and loads them into the execution context due to the creation time. Its important because function declarations are hoisted (they are moved to the top and processed regardless of where they are located) just as variables are, while only the variable declaration of a function expression is hoisted:

// declaration
// function declarations needs to have a name
function sayHello1() {
  alert("Hello");
}

//If the function declaration has no name, it’s considered a function expression 
@carolineartz
carolineartz / luhn_creditcard_validator.rb
Last active August 29, 2015 14:10
Tutoring resource for students DBC P0 Prep
# OBJECTIVES:
# Your class will need to return true or false when we call the #check_card.
# Your class needs to be initialized with a credit card number that is
# exactly 16 digits otherwise you should receive an ArgumentError
# LUHN ALGORITHM FOR CC VALIDATION LOGIC:
# starting with the second to last digit, double every other digit until you
# reach the first digit.
# Sum all the untouched digits and the doubled numbers, first broken down to
@carolineartz
carolineartz / Angular-VS.-jQuery.markdown
Created November 6, 2014 18:39
A Pen by Elijah Fowler.

Angular VS. jQuery

This is a small test showing the markup and JS differences between Angular JS and jQuery.

A Pen by Elijah Fowler on CodePen.

License.

Angular: Toggle a Class on Click

Simple example demonstrating adding a class to an element on 'click' with Angular.

A Pen by Heather Buchel on CodePen.

License.

@carolineartz
carolineartz / html-css-layout-1.md
Last active August 29, 2015 14:08
DBC Phase 0 tips/resources: on float and inline-block layouts (columns).

columns layouts acheived in a few different ways. 2 common ways are using floats or position: inline-block.

learning resource:

css cheatsheet

learnlayout.com - checkout sections: float, clear, clearfix, float layout, inline-block and inline-block layout

inline block vs floats

@carolineartz
carolineartz / unique.js
Created November 5, 2014 19:00
unique value in js array credit: can't remember
var contains = function (haystack, needle) {
return !!~haystack.indexOf(needle);
};
// can be used like so now:
if (contains(items, 3452)) {
// do something else...or console.log("yep");
}
@carolineartz
carolineartz / Asset.rb
Created November 5, 2014 02:54
setup database
require 'sqlite3'
$db = SQLite3::Database.new "<database_name.db>"
module StudentDB
# pry
def self.setup
$db.execute_batch(
<<-SQL
CREATE TABLE students (