Skip to content

Instantly share code, notes, and snippets.

View JakeSidSmith's full-sized avatar
💭
Being awesome 😎

Jake 'Sid' Smith JakeSidSmith

💭
Being awesome 😎
View GitHub Profile
@JakeSidSmith
JakeSidSmith / jswat.md
Last active January 30, 2019 15:31
Crazy javascript madness

jswat

  1. var answer = 0.1 + 0.2;

    0.30000000000000004

  2. var answer = [] + [];

    ''

@JakeSidSmith
JakeSidSmith / poller.ts
Created December 20, 2018 16:07
Class to ease process of polling an endpoint
import axios, { AxiosRequestConfig, AxiosError, AxiosResponse, CancelTokenSource } from 'axios';
interface PollOptions<PollResponse, CompleteResponse> {
interval: number;
shouldContinuePolling: (response: PollResponse | CompleteResponse) => response is PollResponse;
isComplete: (response: PollResponse | CompleteResponse) => response is CompleteResponse;
onStart?: () => any;
onStop?: () => any;
onError: (error: AxiosError) => any;
onComplete: (response: CompleteResponse) => any;
@JakeSidSmith
JakeSidSmith / usage.tsx
Last active October 12, 2018 14:29
wrapThunkAction - correctly types thunk actions as if they had been mapped with dispatch
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { wrapThunkAction } from './somewhere';
import { action } from './actions';
const wrappedAction = wrapThunkAction(action);
interface DispatchProps {
action: typeof wrappedAction;
@JakeSidSmith
JakeSidSmith / README.md
Last active July 13, 2018 09:57
Find bad version of eslint-scope in global node_modules, nvm dir, trash, and current directory.

Running this script locally

  1. cd into your "projects" directory, or whatever folder all of your projects are stored in.

  2. Run the following:

curl -s https://gist.githubusercontent.com/JakeSidSmith/0ddc45b08cacc8152492ba8f2598345b/raw/4fc8d7b4a5b319a3ce4951098c1d2626eb9d8342/find-eslint-scope | bash
@JakeSidSmith
JakeSidSmith / .bash_node
Created June 22, 2018 11:36
Bash profile extension to automatically change NodeJS versions with NVM
#! /usr/bin/env bash
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
COLOR_NONE="\033[1;39m"
NVMRC=".nvmrc"
function check_node_version () {
@JakeSidSmith
JakeSidSmith / show-n-tell-spring-2018.md
Last active April 2, 2018 17:00
Async's Spring 2018 Show n' Tell

[Async's][async] [2018 Spring Show n' Tell][event]

Thursday 5th April, 2018

  • [Full info on the Async website][event]

Speakers gist

Would you like to speak on the night? You'll have five minutes to tell us about something: a project, a library, a technique, a story, or anything else about JavaScript, HTML, CSS, or the wider world of tech.

@JakeSidSmith
JakeSidSmith / brighton-and-hove-meetups.md
Last active March 29, 2018 16:36
List of Brighton & Hove Design, Development, and Various Other Tech / Nerdy Meetups

ANNOUNCEMENT: We've moved all of these meetups to a better maintained website called Brighton Brains - add it to your bookmarks, share it on your social media, etc. :D

Brighton & Hove Design, Development, and Related Meetups

Development

A JavaScript meetup for Brighton & Hove

@JakeSidSmith
JakeSidSmith / key-value-mappings.ts
Created August 25, 2017 08:37
TypeScript exact key value mappings
/* Tested with TypeScript 2.4.2 */
// If you create an object like this, although the keys are correctly inferred, all of the values will be of type string
const obj = {
FOO: 'FOO', // FOO: string
BAR: 'BAR', // BAR: string
};
// You can easily fix this by defining a type for the key values
type KeyValue = 'FOO' | 'BAR';
@JakeSidSmith
JakeSidSmith / aliasify-tsconfig.js
Last active December 6, 2017 17:52
Create aliasify config from tsconfig.json
const tsconfig = require('./tsconfig.json');
const fs = require('fs');
const path = require('path');
const ASTERISK = /\*/g;
const LEADING_DOT_SLASH = /^\.\//;
const CARET = /\^/g;
const { compilerOptions: { paths } } = tsconfig;
@JakeSidSmith
JakeSidSmith / README.md
Last active November 27, 2017 04:48 — forked from hofmannsven/README.md
My simply Raspberry Pi Cheatsheet