This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exercise 1 - OO || !OO | |
// Define a data structure for cars (make and color), and a function | |
// that logs a string like "I'm a red Mercedes" to the console. | |
// Make two versions: a functional version, and a object-oriented version. | |
// Example call for functional version(Couldn't Figure out): | |
var logCar = (function(funcCar){ | |
return function(){ | |
console.log("I'm a " + funcCar.color + " " + funcCar.make); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bottle -> The minimalistic Python Mirco Framework | |
Prequisites: | |
1) Python 2.7 (This comes with the mac) | |
2) pip - python package manager (replacement for easy_install) think gems for Ruby | |
3) virtualenv - manage dependencies created by having multiple projects think rvm for Ruby | |
4) Bottle Module | |
Setup | |
- python -V (check python version should be 2.7.x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install RVM | |
Run in terminal: bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) | |
Add to end profile: echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" | |
OR | |
edit and use utilities/rvm_install.sh: ./utilities/rvm_intstall.sh | |
Basic RVM Commands | |
http://beginrescueend.com/rvm/best-practices/ | |
rvm -v #what version? | |
rvm help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java | |
Write serialized object to a file | |
public static void writeFile(File dest) throws IOException{ | |
FileOutputStream fileStream = new FileOutputStream(dest); | |
ObjectOutputStream os = new ObjectOutputStream(fileStream); | |
os.writeObject(obj); | |
os.close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File.open(fname).read.match(/\"accepted_fields\":\s+\[((\d(,)?)+)\]/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'create basic template e.g. kms:create_template["my template", blog fragment]' | |
task :create, [:name, :content_type_names] => :environment do |t,args| | |
unless args[:name] && args[:content_type_names] | |
puts "Usage: kms:create_template[<name>, <space seperated list of content types>] | |
exit | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ruby | |
start - irb | |
help - help, then String, String#<TAB>, String.chop | |
clear - CTRL+L, system(‘clear’) | |
load file - require “./name.rb” (run keep functions), source “./name.rb” (run keep functions and variables) | |
exit - exit | |
Elixir | |
start - iex | |
help - h e.g h String, h String.<TAB>, String.chop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Prime do | |
def run(n), do: Stream.iterate(1, &(&1 + 1)) |> Stream.filter(&(filter(&1))) |> Enum.take(n) | |
def filter(n) when n < 4, do: true | |
def filter(n), do: Enum.map(2..div(n,2), &(not(rem(n,&1) == 0))) |> Enum.all? | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elixir Keyword Lists are a list of two item tuples where the first element of a tuple is an atom | |
iex(2)> k1 = [{:a, 1}, {:b, 2}, {:c, 3}, {:d, 4}] | |
[a: 1, b: 2, c: 3, d: 4] | |
iex(4)> k1 = [a: 1, b: 2, c: 3, d: 4] #a spoonful of sugar | |
[a: 1, b: 2, c: 3, d: 4] | |
iex(5)> k1 ++ {:b, 1} #not what we want | |
[{:a, 1}, {:b, 2}, {:c, 3}, {:d, 4} | {:b, 1}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(assignment_one_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
perimeter_test() -> ?assert(assignment_one:perimeter({triangle, {3,4,5}}) == 12), | |
?assert(assignment_one:perimeter({right_triangle, {3,4}}) == 12), | |
?assert(assignment_one:perimeter({square, {4,4}}) == 16), | |
?assert(assignment_one:perimeter({rectangle, {4,5}}) == 18). | |
area_test() -> ?assert(assignment_one:area({right_triangle, {3,4}}) == 6), | |
?assert(assignment_one:area({square, {5,5}}) =:= 25), |
OlderNewer