Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️
Building @tellerhq

Stevie Graham stevegraham

🛠️
Building @tellerhq
View GitHub Profile
View migrate.js
document.addEventListener("DOMContentLoaded", function() {
var tellerConnect = TellerConnect.setup({
applicationId: "your_app_id",
skipPicker: true,
onInit: function() {
document.querySelector("button.teller-connect").addEventListener("click", function() {
tellerConnect.open({institution: "chase"})
})
},
onSuccess: function(enrollment) {
@stevegraham
stevegraham / teller_payments.rb
Created May 8, 2018
Teller payment example with signatures
View teller_payments.rb
require "net/https"
require "time"
require "base64"
require "uri"
require "securerandom"
# Load your private key
pkey = OpenSSL::PKey::RSA.new File.read("private_key.pem")
# Create new HTTP request
@stevegraham
stevegraham / payment_example.rb
Created May 8, 2018
Teller payment example with signature
View payment_example.rb
require "net/https"
require "time"
require "base64"
require "uri"
require "securerandom"
# Load your private key
pkey = OpenSSL::PKey::RSA.new File.read("private_key.pem")
# Create new HTTP request
View foo.ex
defmodule Foo do
def bar(%{baz => _}), do: "I wish pattern matching map keys worked"
end
View signup_form.ex
defmodule Teller.Web.SignupForm do
use Form,
email: :email,
password: :password,
password_confirmation: :password
validates :email, presence: true
validates :password, length: [min: 8], confirmation: true
end
@stevegraham
stevegraham / example.ex
Last active Aug 30, 2015
Memorex - a cache for expensive code paths
View example.ex
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
View gist:a319cc39dfc02fbb8a78

http: [compress: true] is set on App.Endpoint

defmodule App.Router do
  use Phoenix.Router

  scope "/", App do
    resources "foo", FooController do
  end
end
View mockery.ex
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
View gist:b4f43cd761973b073882
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
@stevegraham
stevegraham / fizzbuzz.ex
Created Dec 20, 2014
Functional FizzBuzz
View fizzbuzz.ex
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
You can’t perform that action at this time.