Skip to content

Instantly share code, notes, and snippets.

Erik Berlin sferik

Block or report user

Report or block sferik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View eriks_array.rb
# [X] length/size
# [X] push
# [X] [] (slice)
# [X] pop
# [X] first
# [X] last
# [X] shift
# [X] unshift
# [X] each
# [X] select/reject/collect/inject
View wft_range_include.rb
a = 1 # one
b = a - 1 # zero
(b..a).include?(a) #=> true
(b..a).include?(a.to_f) #=> true
(b..a).include?(0.5) #=> true
a = # now
b = a - 1 # 24 hours ago
(b..a).include?(a) #=> true
(b..a).include?(a.to_date) #=> false
View app.js
var server = require('http').createServer(serveFile);
var fs = require('fs');
var ntwitter = require("ntwitter");
var io = require('').listen(server);
function serveFile(request, response){
fs.readFile(__dirname + '/index.html', function(error, data){
if(error) {
response.writeHead(404, {'Content-Type': 'text/html'});
response.write("<html><body>No drank for you!</body></html>");
View twitter.js
var ntwitter = require("ntwitter");
var client = new ntwitter({
consumer_key: process.env["TWITTER_CONSUMER_KEY"],
consumer_secret: process.env["TWITTER_CONSUMER_SECRET"],
access_token_key: process.env["TWITTER_ACCESS_TOKEN"],
access_token_secret: process.env["TWITTER_ACCESS_SECRET"]
var coffee, tea, wine, beer, water;
View fortune_server.js
var fortunes = [
"Have a nice day",
"You look really good today",
"It's your birthday!",
"Never play leapfrog with a unicorn"
var net = require('net');
var server = net.createServer(function(connection){
connection.write("Enter the number of fortunes you want: ");
View a.txt
/Users/sferik/.rbenv/versions/2.0.0-p195/bin/ruby -S rspec ./spec/twitter/action/favorite_spec.rb ./spec/twitter/action/follow_spec.rb ./spec/twitter/action/list_member_added_spec.rb ./spec/twitter/action/mention_spec.rb ./spec/twitter/action/reply_spec.rb ./spec/twitter/action/retweet_spec.rb ./spec/twitter/action_factory_spec.rb ./spec/twitter/action_spec.rb ./spec/twitter/api/direct_messages_spec.rb ./spec/twitter/api/favorites_spec.rb ./spec/twitter/api/friends_and_followers_spec.rb ./spec/twitter/api/geo_spec.rb ./spec/twitter/api/help_spec.rb ./spec/twitter/api/lists_spec.rb ./spec/twitter/api/oauth_spec.rb ./spec/twitter/api/saved_searches_spec.rb ./spec/twitter/api/search_spec.rb ./spec/twitter/api/spam_reporting_spec.rb ./spec/twitter/api/suggested_users_spec.rb ./spec/twitter/api/timelines_spec.rb ./spec/twitter/api/trends_spec.rb ./spec/twitter/api/tweets_spec.rb ./spec/twitter/api/undocumented_spec.rb ./spec/twitter/api/users_spec.rb ./spec/twitter/base_spec.rb ./spec/twitter/basic_user_spec.rb ./
View clean_chains.rb
require 'prime'
Prime.each_with_index.inject(0) do |sum, (number, index)|
puts index + 1 if sum % number == 0
sum += number

WDI Homework - April 29, 2013

JavaScript TODO List

Create a client-side TODO list application in JavaScript.

  • Uses jQuery
  • When you enter text into a box and press the "Add" button, it adds an item to your "TODO" list and clears the text box
  • When you click on a checkbox next to each "TODO" item, it must:

WDI Homework - April 23-24, 2013

Triangle Area

Given the following object, write an area function in JavaScript that calculates the area of triangle:

var triangle = {
  sideA: 3,
  sideB: 4,
  sideC: 5
View google_products_search.rb
require 'json'
require 'open-uri'
require 'uri'
class GoogleProductsSearch
def self.find_all_by_query(query)
file = open("{ENV["GOOGLE_PRODUCTS_API_KEY"]}&country=US&q=#{URI.escape(query)}")
JSON.load(["items"] || []
You can’t perform that action at this time.