Skip to content

Instantly share code, notes, and snippets.

View scottmascio2115's full-sized avatar

Scott Mascio scottmascio2115

View GitHub Profile
Creation of an opposite macro
We want opposite 1 + 1
to return to 0 or essentially run 1 - 1
opposite 1 + 1
Transforms 1 + 1 into an AST
opposite({:+, [], [1,1]}
Our macro would then transform that AST (Abstract syntax tree)
## Distributed code using Nodes
# Elixir docs http://elixir-lang.org/getting-started/mix-otp/distributed-tasks-and-configuration.html
# This blog post http://benjamintan.io/blog/2014/05/25/connecting-elixir-nodes-on-the-same-lan/
iex --sname foo
Results in
foo@computer-name
defmodule Todo do
use GenServer
## Client side code
def start(tasks \\ "") do
{:ok, pid} = GenServer.start(__MODULE__, tasks)
pid
end
def add_task(pid, task) do
@scottmascio2115
scottmascio2115 / zoo.js
Last active December 24, 2015 00:19 — forked from dbc-challenges/zoo.js
function Animal (name, legs) {
this.name = name;
this.legs = legs;
}
Animal.prototype.identify = function() {
console.log("I am a" + this.name "with 2 legs." "," this.name "have" +this.legs "legs");
};
@scottmascio2115
scottmascio2115 / index.html
Last active December 24, 2015 00:09 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@scottmascio2115
scottmascio2115 / index.html
Created September 26, 2013 00:35 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>
@scottmascio2115
scottmascio2115 / reflect_iterate.rb
Created August 12, 2013 12:22
reflect and iterate
# Feel free to ask other people to explain things to you.
#Remember, your understanding is the most important part.
# Include links to all three gists here. Ruby_Racer && Sudoku
# 1. https://gist.github.com/tarynsauer/d6e99f07b25a429cd755
# 2.https://gist.github.com/nlprater/c2af4e1ff3b7074252f6
# 3.https://gist.github.com/bahrieinn/65aee31bb545bbb089f9
# Now, redo your most difficult week review challenge.
@scottmascio2115
scottmascio2115 / racer_utils.rb
Last active December 20, 2015 22:48
Ruby Racer 2
class Die
def initialize(sides = 6)
@sides = sides
end
# Remember: rand(N) randomly returns one of N consecutive integers, starting at 0
# So rand(N) returns a random integer in (0..N-1)
# And 1 + rand(N) returns a random integer in (1..N)
# See: http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-rand
def roll
@scottmascio2115
scottmascio2115 / reflect_on_learning.md
Created August 11, 2013 22:43
reflect_on_learning.

List 10 topics

  1. Driver code
  2. Recursion
  3. Looping
  4. Enumerables
  5. Arrays
  6. Ping pong pairing
  7. Debugging
  8. Pseudocode
  9. Refactoring
# 1: Grab a solution to Roman Numerals
#
# Source: https://gist.github.com/leeacto/ece0c63cfda0d022b536
# Author: Nick lee
# ------------
# 2. Explain the code in plain English
# Given a number, translate that number into a roman numeral.
# You have to create a set of numbers. The assign those numbers letters.
#Take your original number and run it through the set of numbers.