Skip to content

Instantly share code, notes, and snippets.

Nathan Smith nathansmith

Block or report user

Report or block nathansmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nathansmith / get_method_names.ts
Created Aug 5, 2019
Get method names, from object or class instance.
View get_method_names.ts
export function getMethodNames(
apiObject: object = {}
): string[] {
// Assume class instance.
let list = Object.getOwnPropertyNames(
// Detect plain object.
if (list.includes('__proto__')) {
nathansmith / deep_freeze.ts
Created Aug 5, 2019
Recursively freeze an object.
View deep_freeze.ts
export function deepFreeze (
obj: any
): any {
const props = Object.getOwnPropertyNames(obj);
props.forEach(prop => {
const value = obj[prop];
if (
value !== null &&

React 101™

All these examples do essentially the same thing.

return (

10x Developer Code

I came across some code awhile ago that, though I can't share exactly, I wanted to document as a "foot gun."

You should never have a class that can be used both as a parent with helper methods and can be instantiated.

Even if you did, there should never be static and public methods — by the same name — that do different things.

View crunchbase_console.js
Paste this into the console on to remove the
extra overlay upsell stuff.
Example page:

There is a cult of ignorance in the United States, and there always has been. The strain of anti-intellectualism has been a constant thread winding its way through our political and cultural life, nurtured by the false notion that democracy means that "my ignorance is just as good as your knowledge."

— Isaac Asimov



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 /
Last active Jan 6, 2019
Command line snippet to lock icons at "48" size.
nathansmith / dribbble_console_follow.js
Created Nov 1, 2018
Leave this running on your "" 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 / 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
You can’t perform that action at this time.