I hereby claim:
- I am stevegraham on github.
- I am sg (https://keybase.io/sg) on keybase.
- I have a public key whose fingerprint is DB6D 0AB8 BEA8 3D90 E1FC B5A8 9E83 7DE0 28E3 4D82
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
sudo tcpdump -U -In -i en0 -s 2048 -A dst i.instagram.com | ack -o "(?<=Cookie: ).+" --flush > ~/Desktop/cookies |
# Returns methods in the order of definition | |
FooClass.instance_methods(false) | |
=> [:methods, :excluding, :from, :superclass, :returned, :in, :the, :order, :they, :were, :defined] | |
# Returns a sorted list | |
FooClass.instance_methods - FooClass.superclass.instance_methods | |
=> [:defined, :excluding, :from, :in, :methods, :order, :returned, :superclass, :the, :they, :were] | |
# WAT |
module PaymentGatewayCheck | |
@available = nil | |
MUTEX = Mutex.new | |
TASK = PeriodicTask.new(every: 5.seconds, run_immediately: !Rails.env.test?) do | |
begin | |
result = HTTParty.get ENV['PAYMENT_GATEWAY_PING_ENDPOINT'] | |
MUTEX.synchronize { @available = result.success? } | |
rescue SystemCallError | |
MUTEX.synchronize { @available = false } |
require 'net/http' | |
require 'logger' | |
require 'mechanize' | |
logger = Logger.new(STDOUT) | |
req = Net::HTTP::Get.new '/' | |
drop_time = Time.local 2014, 12, 19, 12 | |
req['User-Agent'] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.1.17 (KHTML, like Gecko) Version/7.1 Safari/537.85.10" |
defmodule FizzBuzz do | |
def upto(n) when n > 0, do: 1..n |> Enum.map(&fizzbuzz/1) | |
defp fizzbuzz(n) when rem(n, 15) == 0, do: "FizzBuzz" | |
defp fizzbuzz(n) when rem(n, 3) == 0, do: "Fizz" | |
defp fizzbuzz(n) when rem(n, 5) == 0, do: "Buzz" | |
defp fizzbuzz(n), do: n | |
end |
defmodule Knox.Ecto.Hstore do | |
@behaviour Ecto.Type | |
def type, do: :hstore | |
def blank?, do: false | |
def load(t), do: { :ok, t } | |
def dump(t), do: { :ok, t } | |
def cast(t), do: { :ok, t } | |
end |
defmodule RequestTest do | |
use ExUnit.Case, async: false | |
use Mockery | |
def dsl_test do | |
Mockery.intercept do | |
request = %Request{ method: :post, uri: "http://example.com:3000/users", body: "hello=world", headers: %{ "User-Agent" => "My App" } } | |
response = %Response{ status: 201 } | |
stub_request request, response |
http: [compress: true]
is set on App.Endpoint
defmodule App.Router do
use Phoenix.Router
scope "/", App do
resources "foo", FooController do
end
end
require Memorex | |
Memorex.start_link([]) | |
# Cache this expensive function call, e.g. external service API | |
Memorex.get("unique_cache_key", ttl: 30) do | |
do_some_expensive_shit | |
end | |