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
sferik /
Last active Dec 25, 2019
Why Software Is Eating The World

Why Software Is Eating The World

August 20, 2011

This week, Hewlett-Packard (where I am on the board) announced that it is exploring jettisoning its struggling PC business in favor of investing more heavily in software, where it sees better potential for growth. Meanwhile, Google plans to buy up the cellphone handset maker Motorola Mobility. Both moves surprised the tech world. But both moves are also in line with a trend I've observed, one that makes me optimistic about the future growth of the American and world economies, despite the recent turmoil in the stock market.

In short, software is eating the world.

sferik /
Created Nov 5, 2012
Instructions to install on Ruby 2.0.0 on Mac OS X with homebrew
#!/usr/bin/env sh
brew update
brew install rbenv
brew install ruby-build
brew install openssl
CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` rbenv install 2.0.0-preview1
View future.ex
defmodule Future do
def new(fun) do
fn(x) ->
spawn_link fn ->
value = try do
{ :ok, fun.(x) }
e -> { :error, e }
View 1000 Twitter API Requests (JSON)
$ ab -n 1000 -c 10
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,
Benchmarking (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
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 first_to_finish.rb
module Enumerable
def first_to_finish
threads = collect { |args| { yield(args) } }
loop until done = threads.detect { |t| !t.alive? }
puts [5, 3, 1, 2, 4].first_to_finish { |x| sleep x }
View twitter-friends.rb
require 'csv'
require 'twitter'
def twitter_client
@twitter_client ||= do |config|
config.consumer_key = 'XXXXXX'
config.consumer_secret = 'XXXXXX'
config.access_token = 'XXXXXX'
config.access_token_secret = 'XXXXXX'
View 2.4-bench.rb
require 'benchmark/ips'
def class_integer
0.class == Integer
def version_gte
sferik / passwords_controller.rb
Created Nov 17, 2012 — forked from kazpsp/passwords_controller.rb
StrongParameters with Devise
View passwords_controller.rb
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation, :reset_password_token)
private :resource_params
digraph G {
label="Caddy Architecture"
fontname="Helvetica Neue"
node [shape="ellipse", style="filled", fontname="Helvetica Neue"]
edge [fontname="Helvetica Neue"]
subgraph clusterClient {
You can’t perform that action at this time.