Skip to content

Instantly share code, notes, and snippets.

View oestrich's full-sized avatar
🔡
Making text games

Eric Oestrich oestrich

🔡
Making text games
View GitHub Profile
@oestrich
oestrich / test.rb
Created March 12, 2014 14:40
smartchat test client
require 'faraday'
require 'json'
def hash_password_for_private_key(password, sha_klass = OpenSSL::Digest::SHA256)
sha256 = sha_klass.new
1000.times.inject(password) do |hash, _|
sha256.hexdigest(hash)
end
end
@oestrich
oestrich / encryption.rb
Created July 28, 2015 01:35
encryption benchmark
require 'openssl'
require 'benchmark'
data = "Hello, world!"
Benchmark.bm do |x|
x.report do
private_key = OpenSSL::PKey::RSA.new 4096
public_key = private_key.public_key
@oestrich
oestrich / gist:1225208
Created September 18, 2011 16:02
Ruby DCamp - Backbone Game of Life
<!DOCTYPE html>
<html>
<head>
<title>Backbone game of life</title>
<meta charset='utf-8' />
<script type='text/javascript' src='jquery.js'> </script>
<script type='text/javascript' src='underscore.js'> </script>
<script type='text/javascript' src='backbone.js'> </script>
@oestrich
oestrich / layout_image.xml
Created November 19, 2011 17:29
Android ImageView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/red"
android:adjustViewBounds="true"/>
@oestrich
oestrich / gist:2315434
Created April 6, 2012 00:35
RspecApiDocumentation Send JSON
resource "Order" do
let(:client) { RspecApiDocumentation::TestClient.new(self, :headers => { "HTTP_ACCEPT" => "application/json", "CONTENT_TYPE" => "application/json" }) }
post "/orders" do
parameter :name, "Order name"
let(:name) { "New order" }
let(:raw_post) { params.to_json }
@oestrich
oestrich / Gemfile
Created September 5, 2012 15:37
WebMachine Test
source :rubygems
gem 'webmachine'
gem 'rspec'
gem 'rspec_api_documentation'
gem 'rack-test'
gem 'json_spec'
@oestrich
oestrich / Results
Created September 18, 2012 23:29
Failing OAuth2 feature for rspec_api_documentation pr #51
Feature: Use OAuth2 MAC client as a test client
Background: # features/oauth2_mac_client.feature:2
Given a file named "app_spec.rb" with: # aruba-0.4.11/lib/aruba/cucumber.rb:15
"""
require "rspec_api_documentation"
require "rspec_api_documentation/dsl"
require "rack/builder"
RspecApiDocumentation.configure do |config|
@oestrich
oestrich / notification_printer.rb
Created November 14, 2012 14:45
Instrument every method in a class for metrics
ActiveSupport::Notifications.subscribe(/my_class$/) do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
Rails.logger.warn "%7.2fms %s" % [event.duration, event.name]
end
@oestrich
oestrich / parallel_test_adapter.rb
Created January 30, 2013 18:57
Parallel Faraday Test Adapter
class ParallelTestAdapter < Faraday::Adapter::Test
self.supports_parallel = true
def self.setup_parallel_manager
OpenStruct.new
end
end

Keybase proof

I hereby claim:

  • I am oestrich on github.
  • I am ericoestrich (https://keybase.io/ericoestrich) on keybase.
  • I have a public key ASDfZSNUBY96XScRjsdNmXpz6nHJ0y1XhfVA6MnxOGUG2Qo

To claim this, I am signing this object: