Skip to content

Instantly share code, notes, and snippets.

View nicholasspencer's full-sized avatar

Nico Spencer nicholasspencer

View GitHub Profile
@nicholasspencer
nicholasspencer / tutorial.dart
Created May 14, 2020 05:32
Tutorial widget knockout system
class Tutorial extends StatefulWidget {
final Widget child;
final bool show;
const Tutorial({
@required this.child,
this.show = false,
Key key,
@nicholasspencer
nicholasspencer / scrape_etsy_type_info.sh
Last active April 18, 2019 19:55
curl | pup | jq script to scrape etsy type information
#!/usr/bin/env bash
scrape_type() {
curl https://www.etsy.com/developers/documentation/reference/$1 | pup 'table[id^="resource_fields"] tr:not(:first-child) json{}' | jq '.[] | {"property": .children[0].children[0].text, "type": .children[3].children[0].children[0].text, "secondaryType": (.children[3].children[0].text | try gsub("[\\(\\) ]"; "") catch null) }'
}
scrape_type $1
exit 0
# ./bin/scrape_type.sh apimethod
@nicholasspencer
nicholasspencer / on-demand.swift
Created January 3, 2019 14:52
On-demand nil coalescing infix operator
import Foundation
infix operator ??=: NilCoalescingPrecedence
func ??= <T>(left: inout T?, right: T) -> T? {
left = left ?? right
return left
}
class MyClass {
private var _onDemand: Date?
@nicholasspencer
nicholasspencer / gifplease.sh
Last active March 18, 2019 21:31
Quicktime Screen Recording to GIF
#!/usr/bin/env bash
# converts .mov (quicktime screen recordings) to animated .gif images
# requires ffmpeg and gifsicle which are easily `brew install`'d
gifplease() {
ffmpeg -i $1 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=8 > $1.gif
gif="$(pwd)/$1.gif"
echo "👉 $gif"
open -na Safari "file://$gif"
}
struct HashTable<Key: Hashable, Value> {
private typealias Element = (key: Key, value: Value)
private typealias Bucket = [Element]
private typealias IndexPath = (bucket: Int, index: Int?)
private var buckets: [Bucket]
private(set) var count = 0
public init(capacity: Int) {
@nicholasspencer
nicholasspencer / bind.js
Last active August 29, 2015 14:18
Everytime I stumble across this I die a little inside
var self = this;
@nicholasspencer
nicholasspencer / component.examples.js.jsx
Last active August 29, 2015 14:15
React component styles
// *******************************************
// React Component w/ verbose rendering out-of-line
// *******************************************
var reactRenderCodeElseWhere = function() {
/* maybe do some calculations; smoke some chocolate cigarettes; */
return React.DOM.div (
//attributes
{},
//children
[
@nicholasspencer
nicholasspencer / keybase.md
Last active August 28, 2017 20:13
keybase.md

Keybase proof

I hereby claim:

  • I am nicholasspencer on github.
  • I am nicholasspencer (https://keybase.io/nicholasspencer) on keybase.
  • I have a public key ASAfP6E2ld8s5HdDKTDH-H94Y1NLagYY0rV6vRkaW95hAwo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am nicholasspencer on github.
  • I am nicholasspencer (https://keybase.io/nicholasspencer) on keybase.
  • I have a public key whose fingerprint is A3EB 61B1 A954 D95D 6EF5 13DE 2E38 C954 39E5 0474

To claim this, I am signing this object:

@nicholasspencer
nicholasspencer / Commented code
Last active December 20, 2015 07:09
"Sure I comment my code" seriously wtf.
//
// Intent photoPreviewUploadPageIntent = new Intent(getActivity(), PhotoPreviewUploadPage.class);
// photoPreviewUploadPageIntent.putExtras(bundle);
// if(!TextUtils.isEmpty(action)){
// photoPreviewUploadPageIntent.setAction(action);
// }
// photoPreviewUploadPageIntent.putExtra("requestCode", requestCode);
// activity.startActivityForResult(photoPreviewUploadPageIntent,
// requestCode);
//