Skip to content

Instantly share code, notes, and snippets.

View wmcbain's full-sized avatar

Wyatt McBain wmcbain

View GitHub Profile
@wmcbain
wmcbain / camelCase.js
Created August 4, 2018 00:49
Python API responses with underscores to a sane camelCase response in JS 😊
const camelCase = obj => {
let newObj = {}
for (let key in obj) {
const currentItem = obj[key]
if (!obj.hasOwnProperty(key)) continue
let newKey = key
while (newKey.includes('_')) {
newKey = newKey.replace(/_([a-z|1-9])/g, k => k[1].toUpperCase())
}
044441086af0e46ed5d742e6c424cd72e04f5bc07bf9d0e7c3e74a48580a72cf92a0c0019b07387c5609342dcd9747b579ad0637d022df74e732e9f6d91914b7b6;patrickleet
http://i.imgur.com/ly9WUkt.gif
http://i.imgur.com/idmYx8X.gif
http://i.imgur.com/9XZ0LCt.gif
http://i.imgur.com/pSEkCZZ.gif
http://i.imgur.com/p7lTUwa.gif
http://i.imgur.com/qRZB4of.gif
http://i.imgur.com/jT8ddAj.gif
http://imgur.com/74k8ZGL
http://i.imgur.com/zj45KYV.gif
http://i.imgur.com/RpXy3q6.gif
$ bundle exec rake spec
--------------------------------------------------------------------------------
Running Unit Tests
--------------------------------------------------------------------------------
bundle exec bacon spec/sourcekitten_spec.rb
Jazzy::SourceKitten
extension NSHTTPURLResponse {
public enum HTTPStatus {
case info
case success
case redirect
case clientError
case serverError
@wmcbain
wmcbain / decoder.m
Last active January 23, 2018 10:30
Objective-C Base58 Decoder / Bitcoin Address Validator
#pragma mark Address validation
// C implementation - credits to Gavin Anderseen I believe
-(NSData *)decodeBase58:(const char *)addy bytes:(unsigned char *)bytes {
static const char *base58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
int i, j, c;
const char *p;
memset(bytes, 0, 25);

Keybase proof

I hereby claim:

  • I am wmcbain on github.
  • I am wmcbain (https://keybase.io/wmcbain) on keybase.
  • I have a public key whose fingerprint is 7D56 5D8B E00C B0FB C452 8004 7FD9 EE06 9035 BA75

To claim this, I am signing this object: