Skip to content

Instantly share code, notes, and snippets.

View joeletizia's full-sized avatar

Joe Letizia joeletizia

View GitHub Profile
@joeletizia
joeletizia / clicker-alert.js
Created April 22, 2014 15:56
Elemental / Data Presents Pattern
presenters.ClickerAlert = function(element) {
$(element).on('click', showAlert);
function showAlert(){
alert("Hey, you clicked me!");
}
}
(function($, ns) {
ns('clicker-alert', {
@joeletizia
joeletizia / tmux.sh
Created July 8, 2015 13:46
How to startup up tmux with a partner
# On the host machine, run
tmux -S /tmp/foo
chmod 777 /tmp/foo
# From the remote machine
ssh username@host
tmux -S /tmp/foo attach
@joeletizia
joeletizia / assignment.md
Last active August 29, 2015 14:25
Dakarai Homework

Write the following functions

  1. A function named dog that prints out "Woof!" to the screen.
  2. A function named cat that prints out "Meow." to the screen.
  3. A function named hello_name that takes a string as input and prints out "Hello, name!" where name is the string given as input.
  4. A function named even? that takes a number as input and returns true if the number is evenly divisibly by 2 and false otherwise.
  5. A function named multiple_of? that takes 2 inputs. For example: multiple_of?(2, 4) returns true because 4 is a multiple of 2 (2*2 = 4). multiple_of?(5, 32) returns false because 32 is not a multiple of 5.
  6. A function named count that takes a number as input and prints out all the numbers between 0 and number to the screen.
  7. A function named multiples that takes a number as input, and returns an array containing all results of the given number multiplied by the numbers from 1 to 10. So for multiples(5) the result should be [5,10,15,20,25, ...]
@joeletizia
joeletizia / homework.md
Created July 31, 2015 14:19
Dakarai Homework 2

Dakarai Homework #2

  1. Write a function called stop_sign that prints out the question Which way do you want to turn? and then takes keyboard input from the user. If the input equals left print Turning left!. If the input equals right print Turning right!. If the input is anything other than the two previous options, print Crash!!!
  2. Write a function called spaces that takes a string as input. Return the number or spaces in the string as an integer.
@joeletizia
joeletizia / Winter-func.rb
Created February 6, 2013 02:10
A solution (at least I think it's right...) to http://challenge.signpost.com/leveltwo The Ransom Glad you've made it this far, intrepid friend of Max. To tell you a little about ourselves, our goal is to end winter in Chicago. We've read our Ries and plan to start small, with an MVP. We currently have the resources to build a structure covering …
require 'open-uri'
def adj_sum(multi,x,y)
sum = multi[x][y].to_i
if x > 0
sum += multi[x-1][y].to_i
end
if x < 999
@joeletizia
joeletizia / Logger.cs
Created February 21, 2013 16:56
Logging class
public class SubordinateLoggingContext
{
private static string CONNECTIONSTRING = "mongodb://connotate:connotate@linus.mongohq.com:10002/ConnotateLogs";
MongoServer mongo;
MongoDatabase db;
MongoCollection collection;
public SubordinateLog log;
public SubordinateLoggingContext()
@joeletizia
joeletizia / products.rb
Created December 15, 2015 22:21
Controller resources that are agnostic of content type to be rendered.
module Products
# What if we want to differ the content between iOS and Web?
class IndexResource
def initialize(product_presenters, content_type)
@product_presenters = product_presenters
@content_type = content_type
end
def render(rendering_engine = RenderingEngine)
rendering_engine.render(partial_path, product_presenters: product_presenters)
@joeletizia
joeletizia / products.rb
Created December 15, 2015 22:21
Controller resources that are agnostic of content type to be rendered.
module Products
# What if we want to differ the content between iOS and Web?
class IndexResource
def initialize(product_presenters, content_type)
@product_presenters = product_presenters
@content_type = content_type
end
def render(rendering_engine = RenderingEngine)
rendering_engine.render(partial_path, product_presenters: product_presenters)
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:dbfile => ":memory:"
)
@joeletizia
joeletizia / parameterize-demo.rb
Created April 21, 2013 23:23
A demo of parameterize function in ActiveSupport
"Joe Letizia's awesome blog 2.0".parameterize
# => "joe-letizia-s-awesome-blog-2-0"