Skip to content

Instantly share code, notes, and snippets.

View danmayer's full-sized avatar

Dan Mayer danmayer

View GitHub Profile
@danmayer
danmayer / churn_swagger_client.rb
Created January 26, 2014 19:53
churn swagger client
$:.unshift "#{File.dirname(__FILE__)}/lib"
require "swagger"
# Get request API endpoints
require "index_api"
require "project_name_api.rb"
require "project_path_api.rb"
# Post request endpoints
@danmayer
danmayer / gist:8610207
Created January 25, 2014 01:11
success for one endpoint
./bin/runscala.sh -DskipErrors com.wordnik.swagger.codegen.BasicRubyGenerator http://churn.picoappz.com/api-docs "key"
base path is http://churn.picoappz.com/api-docs
********* Failed to read swagger json!
Error: Operation - responseClass | missing required field
**** ignoring errors and continuing
swagger version: 1.2
basePath:
api version: 1.0
missing models: Set()
----------
@danmayer
danmayer / gist:7295057
Created November 3, 2013 21:28
to cook
Crepes with veggies: http://projects.washingtonpost.com/recipes/2013/07/10/ratatouille-tomato-crepes/
Corn cakes, if there is still any corn tomorrow: http://www.nytimes.com/recipes/1014967/sweet-corn-blini.html
Stuffed peppers: http://www.nytimes.com/recipes/1014968/feta-stuffed-peppers.html
Chili mac and cheese; http://www.gracelaced.com/2011/09/26/baked-green-chile-mac-and-cheese/
@danmayer
danmayer / tap_with_each.rb
Created November 2, 2013 16:34
tap with each
# do this opposed to each_with_object or inject
# from http://phrogz.net/tap-vs-each_with_object
by_id = {}.tap{ |h| items.each{ |item| h[item.id] = item } }
# logstash config
input {
syslog {
type => syslog
port => 514
}
}
output {
stdout { debug => true debug_format => "json"}
#!/usr/bin/env ruby
require 'rest_client'
require 'net/http'
require 'benchmark'
URL = 'https://www.livingsocial.com/deals/753290-tacos-and-margaritas-for-two-or-four'
time = Benchmark.realtime do
(1..100).each {
url = URI.parse(URL)
req = Net::HTTP::Get.new(url.path)
@danmayer
danmayer / gist:5087142
Created March 5, 2013 00:57
read later
Facebook is one of the most feature-rich apps available for Android. With features like push notifications, news feed, and an embedded version of Facebook Messenger (a complete app in its own right) all working together in real-time, the complexity and volume of code creates technical challenges that few, if any, other Android developers face--especially on older versions of the platform. (Our latest apps support Android versions as old as Froyo--Android version 2.2--which is almost three years old.)
One of these challenges is related to the way Android's runtime engine, the Dalvik Virtual Machine, handles Java methods. Late last year we completed a major rebuild of our Android app (https://www.facebook.com/notes/facebook-engineering/under-the-hood-rebuilding-facebook-for-android/10151189598933920), which involved moving a lot of our code from JavaScript to Java, as well as using newer abstractions that encouraged large numbers of small methods (generally considered a good programming practice). Unfortuna
@danmayer
danmayer / gist:5078067
Created March 3, 2013 20:11
Just a tip on working with RVM inside scripts
#when scripting against rvm with a terminal shell, you might need to source this to use RVM files etc, tip from LS chat room
source ~/.rvm/scripts/rvm
@danmayer
danmayer / gist:4083050
Created November 16, 2012 01:21
test thoughts
So agree with @davetron5000 that defects to users are the most important to prevent.
I also agree that a test failure doesn't mean a defect occurred as tests themselves
often just are bad tests that don't test what they should. While you do have to maintain
and think about a test suite, well written tests should be entirely isolated.
The app code you do need to reason about the changes of the code effect other pieces of
the application. So while a buggy tests might be a bit flaky, if it just passes and I am
not specifically working with that test it isn't increasing my thought load while reasoning
about the code structure.
I still think people should maintain and keep clean tests, and unless you are doing payments,
@danmayer
danmayer / ruby_number_examples
Created June 25, 2012 21:28
Ruby number parsing
>> Integer('1001')
=> 1001
>> Integer('1001a')
ArgumentError: invalid value for Integer: "1001a"
from (irb):26:in `Integer'
from (irb):26
#note this is very odd, so is '10a100'.to_i
>> '1001a'.to_i
=> 1001
>> Float('1001.0')