Skip to content

Instantly share code, notes, and snippets.

@aviflombaum
aviflombaum / methods.rb
Created October 7, 2013 14:22
An explanation of methods.
def method
okay
end
module Kernel
def caller_method_name
parse_caller(caller(2).first).last
end
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = Regexp.last_match[1]
line = Regexp.last_match[2].to_i
method = Regexp.last_match[3]
def will_this_work
puts "Test"
end
$('form a.add_child').click(function() {
// The link that was clicked on has a data-association attribute that points it to the correct ID to clone.
var association = $(this).attr('data-association');
// Grab the template of the fields you want to copy, convert it to a string via the html() method
var template = $('#' + association + '_fields_template').html();
// Create a random number to replace the ID / name
var regexp = new RegExp('new_' + association, 'g');
var new_id = new Date().getTime();
// Replace and Insert
$(this).parent().before(template.replace(regexp, new_id));
# Here is how I would implement Fizzbuzz with objects
# The main issue with your class is what's called
# single responsibility principle
# classes should do one thing and be about
# instances of those classes
# the fizzbuzz class should be about the loop
# just solving fizzbuzz individually
class Fizzbuzz
attr_accessor :value
@aviflombaum
aviflombaum / oo_jukebox.rb
Created October 18, 2012 00:53 — forked from joshrowley/oo_jukebox.rb
Object Oriented Jukebox (with Session class)
class Song
attr_accessor :name
@@song_library = []
def self.all
@@song_library
end
def initialize(name)
@aviflombaum
aviflombaum / List of Programmers You Should Know About.txt
Created September 28, 2012 18:23
Programmers I plan on covering at Flatiron School
matz
kent beck
roy fielding
martin fowler
tim berners lee
david heniemer hansing
john resig
jesse james garret
_why the lucky stiff
marc anderseen
@aviflombaum
aviflombaum / new_bashrc.sh
Created August 11, 2012 09:52 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
@aviflombaum
aviflombaum / _form.html.erb
Created July 25, 2012 02:57
app/models/song.rb
<%= f.fields_for :artist do |artist_form| %>
<div class="field">
<%= artist_form.label :name, 'Artist Name' %><br />
<%= artist_form.text_field :name %>
</div>
<% end %>