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

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
sferik / install-ruby-2.0.0.sh
Created Nov 5, 2012
Instructions to install on Ruby 2.0.0 on Mac OS X with homebrew
View install-ruby-2.0.0.sh
#!/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) }
rescue
e -> { :error, e }
end
View 1000 Twitter API Requests (JSON)
$ ab -n 1000 -c 10 http://twitter.com/help/test.json
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking twitter.com (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('socket.io').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| Thread.new { yield(args) } }
loop until done = threads.detect { |t| !t.alive? }
threads.each(&:kill)
done.value
end
end
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 ||= Twitter::REST::Client.new do |config|
config.consumer_key = 'XXXXXX'
config.consumer_secret = 'XXXXXX'
config.access_token = 'XXXXXX'
config.access_token_secret = 'XXXXXX'
end
View 2.4-bench.rb
require 'benchmark/ips'
def class_integer
0.class == Integer
end
def version_gte
RUBY_VERSION >= '2.4'
end
@sferik
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)
end
private :resource_params
end
View caddy.dot
digraph G {
label="Caddy Architecture"
labelloc="top"
fontsize=20
fontname="Helvetica Neue"
node [shape="ellipse", style="filled", fontname="Helvetica Neue"]
edge [fontname="Helvetica Neue"]
peripheries=0
rankdir="LR"
subgraph clusterClient {
You can’t perform that action at this time.