Skip to content

Instantly share code, notes, and snippets.

Nathan Smith nathansmith

View GitHub Profile
View hockey_national_anthem_story.md

This past week a bunch of us from InVision were at a minor league hockey game in Austin.

I was waiting in line at one of the restaurants, just outside the arena entrance. I got to the front of the line, and was about to order, when the national anthem could be heard from inside the arena.

I look up from the menu, and notice that the entire staff is standing still, smiling, with their hands over their hearts. Realizing that the national anthem is being played, I do the same.

My coworker (from Europe) is to my immediate right, in front of another cash register, and he's also begun looking up from his menu.

Coworker: "Hmm, I think I would like to order the…"

@nathansmith
nathansmith / lock_mac_icon_size.md
Last active Jan 6, 2019
Command line snippet to lock icons at "48" size.
View lock_mac_icon_size.md
@nathansmith
nathansmith / dribbble_console_follow.js
Created Nov 1, 2018
Leave this running on your "dribbble.com/username/followers" page, to auto-follow everyone back.
View dribbble_console_follow.js
// ==================
// Scroll page timer.
// ==================
setInterval(function() {
// NOT end of page?
if (!$('.null-message').length) {
// Get offset.
var offset = document.body.scrollHeight
@nathansmith
nathansmith / get_parents_example.ts
Last active Nov 13, 2018
TypeScript example, for a friend. Explaining types, interfaces, and tuples.
View get_parents_example.ts
// Possible `gender` values.
type Gender = 'male' | 'female' | 'other'
// Generic `person` interface.
interface IPerson {
// Specific string.
gender: Gender
// Any string.
name: string
View get_siblings.js
// Gets siblings of element.
const getSiblings = (el) => {
// Array method.
const f = Array.prototype.forEach
// Get children.
const children = el.parentNode.children
// Set in loop.
const siblings = []
@nathansmith
nathansmith / query_splitter.js
Last active Aug 17, 2018
This method splits apart a query string and converts it into an regular object.
View query_splitter.js
/*
This method splits apart a
query string and converts
it into an regular object.
*/
const querySplitter = (url = '') => {
// Split apart.
const parts = url.split('?')
const query = parts[1] || parts[0]
const pairs = (query || '').split('&')
@nathansmith
nathansmith / on_event.js
Last active Apr 14, 2018
Event delegation helper.
View on_event.js
/*
// Used like so:
onEvent('click', '.foo', (el) => {
// Element that was clicked.
console.log(el)
})
*/
// Event delegation helper.
const onEvent = (event, selector, f) => {
@nathansmith
nathansmith / .eslintrc.json
Last active Apr 18, 2018
My ESLint options file.
View .eslintrc.json
{
"extends": [
"standard",
"standard-react"
],
"globals": {
"afterAll": true,
"afterEach": true,
"beforeAll": true,
"beforeEach": true,
@nathansmith
nathansmith / apollo_query_and_mutation.js
Last active Aug 17, 2018
Example of Apollo's declarative "query" and "mutation" syntax.
View apollo_query_and_mutation.js
// Dependencies.
import React from 'react'
import PropTypes from 'prop-types'
import {Mutation, Query} from 'react-apollo'
// Mutations and queries.
import MY_MUTATION from './my_mutation'
import MY_QUERY from './my_query'
// UI components.
@nathansmith
nathansmith / cloud_app_file_delete.js
Created Mar 8, 2018
This will chew through all the pages within Cloud App's web interface, and delete all files.
View cloud_app_file_delete.js
// Run in console.
(function ($) {
var checkbox = $('#select-all-drops')
var select = $('#actions-select').find('select')
var button = $('#choose-action')
function f () {
if (!checkbox.is(':checked')) {
checkbox.click()
}
You can’t perform that action at this time.