Skip to content

Instantly share code, notes, and snippets.

@yesezra
yesezra / codeacross-final.html
Last active December 14, 2015 03:28
A baseline webpage used at Code Across NYC (http://www.meetup.com/openny/events/103151862/) to introduce people to programming through Javascript and open data. This is not the best example of good HTML (or Javascript), but we used it as a platform for exploration.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<input type="submit" id="submit"></input><br>
<script>
$(function(){
@yesezra
yesezra / instructions.md
Last active December 10, 2015 01:09
Printing Facebook mugshots for a party.

Using the Facebook Graph Explorer, perform this query. Make sure you have permissions to access users' photos. {event-id}/invited?fields=picture

Grab the JSON that results, and copy/past the array under the "data" attribute to attendees.json

In Ruby,

require 'json'
@yesezra
yesezra / excitement_validator.rb
Created August 3, 2012 05:24
Testing custom ActiveRecord validators with rspec and with_model
class ExcitementValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value =~ /.*!/
record.errors.add attribute, (options[:message] || "must end with an exclamation point")
end
end
end
@yesezra
yesezra / .profile
Created July 30, 2012 20:53
Bash alias to start a web server in the current directory
alias servhere="ruby -rwebrick -e'server=WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd);trap(\"INT\"){server.shutdown};server.start'"
@yesezra
yesezra / include.rb
Created March 12, 2012 04:52
It shouldn't be this hard
module Hi
def self.included(base)
base.class_eval do #Enumerable
def hello
puts "hello"
end
end
end
end
@yesezra
yesezra / gist:1090813
Created July 18, 2011 22:10
Cucumber/Capybara/slow javascript secret sauce
When /^I wait until "([^"]*)" is visible$/ do |selector|
wait_until(5) {page.has_css?("#{selector}", :visible => true)}
end
@yesezra
yesezra / append a line in sed
Created October 27, 2010 23:55
for posterity :(
task :gem_path do
run <<-EOC
sed '1 a \ENV["GEM_PATH"] = File.expand_path("~/.gems")' #{current_path}/config/preinitializer.rb > ~/tmpfile
EOC
run "mv ~/tmpfile #{current_path}/config/preinitializer.rb"
end
Ext.setup({
icon: 'icon.png',
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: false,
onReady: function() {
Ext.regModel('User', {
fields: [
{name: 'name', type: 'string'},
{name: 'password', type: 'password'},