Skip to content

Instantly share code, notes, and snippets.

@wsmoak
wsmoak / gist:e113839f2113efc38d71
Created August 23, 2015 20:28
HTTPoison response
response = ChargifyV2.get!("/calls/" <> call_id)
errors = response.body[:call]["response"]["result"]["errors"]
IO.inspect errors
[%{"attribute" => "customer.first_name",
"message" => "First name: cannot be blank."},
%{"attribute" => "customer.last_name",
"message" => "Last name: cannot be blank."},
%{"attribute" => "customer.email",
"message" => "Email address: cannot be blank."},
@wsmoak
wsmoak / gist:5e7c09630443841fbf77
Last active August 29, 2015 14:27
mix phoenix.new hangs on deps.get
$ mix phoenix.new test_project
[...]
* creating test_project/web/static/assets/robots.txt
* creating test_project/web/static/assets/images/phoenix.png
* creating test_project/web/static/assets/favicon.ico
Fetch and install dependencies? [Yn] Y
* running npm install && node node_modules/brunch/bin/brunch build
* running mix deps.get
[info] Running MyApp_802337.Endpoint with Cowboy on http://localhost:4000
02 Aug 20:58:34 - info: compiled 3 files into 2 files, copied 3 in 8060ms
[info] GET /api/tasks/1.json
[debug] Processing by MyApp_802337.TaskController.show/2
Parameters: %{"format" => "json", "id" => "1.json"}
Pipelines: [:api]
[info] Sent 400 in 456ms
[error] #PID<0.294.0> running MyApp_802337.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /api/tasks/1.json
@wsmoak
wsmoak / gist:278be60cc09421d4b9b6
Last active August 29, 2015 14:24
Logger output from Elixir OAuth2 Fitbit.get_token
21:05:35.526 request_id=7OAOqWxZPN0KhWAW/0p7 [info] %OAuth2.AccessToken{access_token: nil, client: %OAuth2.Client{authorize_url: "https://www.fitbit.com/oauth2/authorize", client_id: "22ABCD", client_secret: "c08ac2a9XXXXXXXa55caffb21292", headers: [{"Content-Type", "application/x-www-form-urlencoded"}, {"Accept", "application/json"}], params: %{"client_id" => "229MBF", "client_secret" => "c08ac2aXXXXXXXXXa55caffb21292", "code" => "e590a00XXXXXXXXXX1bb1d43d2906b515408", "grant_type" => "authorization_code", "redirect_uri" => "http://lvh.me:4000/auth/callback"}, redirect_uri: "http://lvh.me:4000/auth/callback", site: "https://api.fitbit.com", strategy: Fitbit, token_method: :post, token_url: "https://api.fitbit.com/oauth2/token"}, expires_at: nil, other_params: %{"errors" => [%{"errorType" => "oauth", "fieldName" => "n/a", "message" => "No Authorization header provided in the request. Each call to Fitbit API should be OAuth signed"}], "success" => false}, refresh_token: nil, token_type: "Bearer"}
In this bit of http://elixir-lang.org/getting-started/case-cond-and-if.html
Clauses also allow extra conditions to be specified via guards:
iex> case {1, 2, 3} do
...> {1, x, 3} when x > 0 ->
...> "Will match"
...> _ ->
...> "Won't match"
...> end
@wsmoak
wsmoak / gist:4d034431a9b4907ea8f1
Created July 2, 2015 13:11
phoenix heroku troubleshooting
$ git push heroku master
Counting objects: 57, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (57/57), 48.86 KiB | 0 bytes/s, done.
Total 57 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Fetching custom git buildpack... done
@wsmoak
wsmoak / gist:79882c4e41d7ac4bfd19
Last active August 29, 2015 14:24
mix troubleshooting
Following http://www.phoenixframework.org/v0.14.0/docs/installation
I've run into this:
$ mix local.hex
** (Mix) Could not access url https://s3.amazonaws.com/s3.hex.pm/installs/list.csv, error: {:failed_connect, [{:to_address, {'s3.amazonaws.com', 443}}, {:inet, [:inet], :eperm}]}
$ curl https://s3.amazonaws.com/s3.hex.pm/installs/list.csv
0.0.1,0.13.0-dev
0.1.0,0.13.1-dev
0.1.1,0.13.1-dev
@wsmoak
wsmoak / component-default-and-required
Created May 4, 2015 17:47
Chargify - Default component quantity to 1 and require quantity to be > 0
$(function () {
var component1 = $("#component_allocated_quantity_XXXXX");
component1.val(1);
$("#subscription_submit").click(function(){
if ( component1.val() <= 0 ) {
component1.addClass("field-error");
return false;
@wsmoak
wsmoak / chargify-field-error-css
Last active August 29, 2015 14:16
Chargify Custom JavaScript and Custom CSS
.field-error {
color: #b94a48 !important;
background: #f2dede !important;
border: solid 1px #eed3d7 !important;
}
@wsmoak
wsmoak / gist:49ea3b44c40a113c180b
Created February 21, 2015 17:55
Chargify - Remove coupon success message
function removeCouponSuccessMessage() {
coupon_text = $('#long_coupon_message').find(".success_message");
coupon_text.text("");
};
$(document).bind("afterSummaryRefresh", removeCouponSuccessMessage);