Skip to content

Instantly share code, notes, and snippets.

@charleyhine
charleyhine / tesla.rb
Last active September 22, 2018 19:28
Tesla API
require 'httparty'
require 'pp'
class Tesla
TESLA_CLIENT_ID = '81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384'
TESLA_CLIENT_SECRET = 'c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3'
include HTTParty
base_uri 'https://owner-api.teslamotors.com'
@charleyhine
charleyhine / shift_api.md
Last active May 20, 2019 16:51
Shift API

Shift API

Custodians (companies and developers) integrate with the Shift API to create and manage branded debit cards and cardholder data. We've tried to make this documentation user-friendly and example-filled, but please drop us a line with any questions. If you're planning to use our API in production, you should take a look at Metropolitan Commercial Bank's privacy policy.

Guide

@charleyhine
charleyhine / 0_reuse_code.js
Created July 20, 2016 00:01
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@charleyhine
charleyhine / api_errors.md
Last active October 15, 2015 21:45
Example API Error Reponses
status code 401

{
  "error": {
    "type": "invalid_request_error",
    "message": "Authentication to the API occurs via HTTP Basic Auth"
  }
}
@charleyhine
charleyhine / getResponse.java
Last active September 30, 2015 23:54
Simple GET with countdown
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.HttpURLConnection;
import java.nio.charset.Charset;
private String getResponse(URL url){
try {
HttpURLConnection c = url.openConnection();
c.setReadTimeout(1000); // 1 second
@charleyhine
charleyhine / keybase.md
Created September 9, 2015 01:06
keybase.md

Keybase proof

I hereby claim:

  • I am charleyhine on github.
  • I am charley (https://keybase.io/charley) on keybase.
  • I have a public key whose fingerprint is CB9F EC53 0F65 E580 BFE1 A27E F929 A025 4978 14B8

To claim this, I am signing this object:

btc_r_tx = Bitcoin::P::Tx.new(tx_data)
btc_r_key = Bitcoin::Key.from_base58(private_key)
hash = btc_r_tx.signature_hash_for_input(input_index, redeem_script)
btc_r_key.sign(hash)
btc_key = Bitcoin::Key.from_base58(get_path_pk(sig))
hash = @btc_r_tx.signature_hash_for_input(input['input_index'], input['redeem_script'])
signat = btc_key.sign(hash)
@charleyhine
charleyhine / gist:5457d2d3a36b17f7f820
Created February 9, 2015 18:50
Receive Chain.com Notification (Address)
def result
tx = JSON.parse(request.raw_post)
type = tx['payload']['type']
confs = tx['payload']['confirmations']
amount_s = tx['payload']['received']
tx_id = tx['payload']['transaction_hash']
addr = tx['payload']['address']
render nothing: true, status: 200
end
{
"address": {
"address": "1kf93kf...",
"transaction": {
"hash": "48d4425e68...",
"address_sent": 0,
"address_received": 4000,
"confirmations": 5
}
}