Skip to content

Instantly share code, notes, and snippets.

View davingee's full-sized avatar

Scott Smith davingee

View GitHub Profile
@davingee
davingee / flatten_ints
Last active May 30, 2018 18:52
This is an Array instance method that flattens any kind of array or array of arrays that contain integers (Fixnum)
require 'rspec'
class Array
def flatten_ints(all=[])
self.each do |item|
if item.class == Array
item.flatten_ints(all)
else
unless item.class == Fixnum
raise TypeError.new "This Methos is only for flattening Fixnums"
module ActiveRecord
module Type
class Json < ActiveModel::Type::Value
include ActiveModel::Type::Helpers::Mutable
def deserialize(value)
value = '{}' if value.is_a?(::NilClass)
return value unless value.is_a?(::String)
ActiveSupport::JSON.decode(value) rescue nil
end
end
require "formula"
class BrowsermobProxy < Formula
homepage "http://bmp.lightbody.net/"
url "https://github.com/lightbody/browsermob-proxy/releases/download/browsermob-proxy-2.1.4/browsermob-proxy-2.1.4-bin.zip", :using => :curl
sha1 "27c4080411adff919586e909c664c73bebb8ba8bfcaea259ce58327222e5e8fb"
version "2.1.4"
def install
prefix.install Dir["*"]
end