Skip to content

Instantly share code, notes, and snippets.

View wmcbain's full-sized avatar

Wyatt McBain wmcbain

View GitHub Profile

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:

@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);
extension NSHTTPURLResponse {
public enum HTTPStatus {
case info
case success
case redirect
case clientError
case serverError
$ bundle exec rake spec
--------------------------------------------------------------------------------
Running Unit Tests
--------------------------------------------------------------------------------
bundle exec bacon spec/sourcekitten_spec.rb
Jazzy::SourceKitten
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
044441086af0e46ed5d742e6c424cd72e04f5bc07bf9d0e7c3e74a48580a72cf92a0c0019b07387c5609342dcd9747b579ad0637d022df74e732e9f6d91914b7b6;patrickleet
@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())
}

Keybase proof

I hereby claim:

  * I am wmcbain on github.   * I am wmcbain (https://keybase.io/wmcbain) on keybase.   * I have a public key ASBFVUH8JRFBfk8vc0h1TJgmBvyxqOE7M9tddtysFeNeQwo

To claim this, I am signing this object:

@wmcbain
wmcbain / useSize.tsx
Last active November 17, 2021 21:43
Small little hook to use in TypeScript React Native apps to get the size of a component onLayout
import { useCallback, useState } from 'react';
import { LayoutChangeEvent } from 'react-native';
export const useSize = (): [
{
height: number;
width: number;
},
(event: LayoutChangeEvent) => void
] => {
@wmcbain
wmcbain / machine.js
Created March 5, 2020 00:59
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions