Skip to content

Instantly share code, notes, and snippets.

View ryanwilsonperkin's full-sized avatar
😅

Ryan Wilson-Perkin ryanwilsonperkin

😅
View GitHub Profile
{"foo": "bar"}
@ryanwilsonperkin
ryanwilsonperkin / README.md
Last active April 8, 2022 14:01
Minimal reproduction of timestamp bug in webpack-cli watch mode

Minimal reproduction of a bug in webpack-cli causing the timestamp that gets output on file change to be off by 1000x

Steps to reproduce:

  • Use this file set
  • Run npm watch
  • Modify the index.js file to trigger a recompile

The modified datetime that is specified in the resulting log will be tens of thousands of years in the future. Valid as of webpack-cli v4.9.2

@ryanwilsonperkin
ryanwilsonperkin / example.js
Created January 27, 2021 19:55
Comparison of different import/re-export types
export default function a() {
return "a";
}
export function b() {
return "b";
}
export function c() {
return "c"
@ryanwilsonperkin
ryanwilsonperkin / is-type.ts
Created November 25, 2020 14:07
TS Type-safe tester for __typename on a GraphQL object
interface TypenameObject {
__typename: string;
}
function isType<O extends TypenameObject, T extends O['__typename']>(obj: O, typename: T): boolean {
return obj.__typename === typename;
}
@ryanwilsonperkin
ryanwilsonperkin / dog
Last active January 20, 2021 18:58
A script that treats arguments as DataDog queries and opens them in a notebook
#!/usr/bin/env ruby
# frozen_string_literal: true
# usage: dog query1 query2 ...
# Opens a new DataDog notebook with the provided queries
# When given no arguments, just opens a new notebook
require 'cgi'
require 'json'
URI_BASE = 'https://shopify.datadoghq.com/notebook'
@ryanwilsonperkin
ryanwilsonperkin / clone.py
Created May 17, 2020 17:08
Clone all repos from an organization
#!/usr/bin/env python3
"""
clone.py
A script for downloading all of your organization's GitHub repos.
usage: GITHUB_ACCESS_TOKEN=foobar python3 clone.py <organization>
Your GITHUB_ACCESS_TOKEN is created by following the steps in this guide:
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
@ryanwilsonperkin
ryanwilsonperkin / App.tsx
Created November 8, 2019 16:57
An example of using React Context to make data available to deeply nested components
import React from "react";
import { ThemeProvider } from "./Theme";
import ToggleTheme from "./ToggleTheme";
import ThemedText from "./ThemedText";
const App: React.FC = () => (
<ThemeProvider>
<ToggleTheme />
<ThemedText>Hello World</ThemedText>
</ThemeProvider>
@ryanwilsonperkin
ryanwilsonperkin / Dockerfile
Created March 12, 2019 20:00
Comparing the use of apt-get vs apt-fast for installing packages in Debian
# A standard Debian container extended with apt-fast (https://github.com/ilikenwf/apt-fast/)
FROM debian
LABEL maintainer="rwilsonperkin@waveapps.com"
# Install gnupg to allow apt-key verification, time to allow profiling
RUN apt-get update
RUN apt-get install -y gnupg time
# Set up PPA for apt-fast
RUN echo deb http://ppa.launchpad.net/apt-fast/stable/ubuntu bionic main >> /etc/apt/sources.list.d/apt-fast.list \
@ryanwilsonperkin
ryanwilsonperkin / flaky.py
Last active February 26, 2019 16:51
Fetch a list of flaky tests form a CircleCI project
#!/usr/local/bin/python3
"""
@author Ryan Wilson-Perkin
Fetch a list of flaky tests from a CircleCI project.
Searches the last 30 builds that have failed on the master branch, downloads any
junit.xml artifacts it finds for them, and reports the tests that have failed.
Branch name, test results file, number of builds, and number of results are all
@ryanwilsonperkin
ryanwilsonperkin / commits.py
Created February 26, 2019 03:32
Count all the lines I've ever changed on GitHub
#!/usr/local/bin/python3
"""
Count all the lines I've ever changed on GitHub
Setup:
pip install requests tqdm GitPython
Usage:
./commits.py
"""