Skip to content

Instantly share code, notes, and snippets.

View iansu's full-sized avatar

Ian Sutherland iansu

View GitHub Profile
### Keybase proof
I hereby claim:
* I am iansu on github.
* I am iansu (https://keybase.io/iansu) on keybase.
* I have a public key whose fingerprint is B381 B817 42ED D871 EA20 F75D 50B9 2C39 4854 3ABC
To claim this, I am signing this object:
@iansu
iansu / cd.bash
Created March 30, 2015 23:03
Bash cd hook
cd() {
if [[ $1 =~ ^[\.]{3,}$ ]]; then
# rewrite ... as ../../ etc.
directory="../"
depth=${#1}
for i in `seq 3 $depth`; do
directory+=../
done
@iansu
iansu / fizzbuzz.rb
Last active June 7, 2016 21:22
FizzBuzz in Ruby
for i in 1..100
print "#{i} "
print "fizz" if i % 3 == 0
print "buzz" if i % 5 == 0
print "\n"
end
@iansu
iansu / butter.ts
Created February 12, 2021 17:00
Butter CMS Integration
import Butter from 'buttercms';
const butter = Butter('api_key');
const getHomePage = async () => {
const homePage = await butter.page.retrieve('*', 'sample-page');
return homePage.data.data;
};
@iansu
iansu / README.md
Last active March 1, 2021 08:40
Create React App 4.0 Alpha Testing

Create New App

JavaScript Template

npx create-react-app@next --scripts-version=@next --template=cra-template@next my-js-app

TypeScript Template

npx create-react-app@next --scripts-version=@next --template=typescript@next my-ts-app

@iansu
iansu / machine.js
Created March 16, 2021 02:47
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@iansu
iansu / npm.js
Created May 18, 2021 21:54
A ScriptKit script to search npm
// Menu: npm
// Description: Search npm
// Author: Ian Sutherland
// Twitter: @iansu
await arg("Search query:", async () => {
let query = await arg("Search query:")
exec(`open https://www.npmjs.com/search?q=${query}`)
})
@iansu
iansu / resources.md
Last active October 14, 2021 17:24
The Past, Present, and Future of JavaScript
@iansu
iansu / dataloader.js
Last active December 8, 2021 19:50
Minimal Dataloader implementation
/*
* This is a minimal implementation of Dataloader. This implementation leaves out the caching functionality
* and skips most of the error handling so it's not suitable to use in production. This is meant to help
* you understand how Dataloader works. Once you understand this code check out the full Dataloader code:
* https://github.com/graphql/dataloader
*/
class Dataloader {
constructor(batchFunction) {
this.batchFunction = batchFunction;
@iansu
iansu / README.md
Last active April 5, 2022 17:21
Using React 17 and the new JSX transform with Create React App 4.0 Alpha

Using React 17 and the new JSX transform with Create React App 4.0 Alpha

Create React App 4.0 is currently in alpha and supports using React 17 and the new JSX transform. To use it, follow these instructions.

Create a new app

Create a new app with npx create-react-app@next --scripts-version=@next --template=cra-template@next my-js-app

Update to React 17