Skip to content

Instantly share code, notes, and snippets.

View deecewan's full-sized avatar

David Buchan-Swanson deecewan

View GitHub Profile
@deecewan
deecewan / prefer_rich_diffs.js
Created October 11, 2019 04:16
A Tampermonkey script to default to the rich diff for files in a PR if/when they exist
// ==UserScript==
// @name Prefer Rich Diffs
// @namespace http://deecewan.com/
// @version 0.1
// @description default to rich diffs when they exist for a given filetype
// @author You
// @match https://github.com/*
// ==/UserScript==
(function() {
@deecewan
deecewan / chat_changer.js
Created May 8, 2019 00:21
Tampermonkey scipt to change chat windows with a keypress
// ==UserScript==
// @name Chat window changer
// @namespace http://deecewan.com
// @version 0.1
// @description try to take over the world!
// @author David Buchan-Swanson
// @match https://tanda.facebook.com/chat/t/*
// @grant none
// ==/UserScript==
@deecewan
deecewan / refinement.js
Last active August 13, 2018 04:19
This is why flow invalidates type refinements at seemingly arbitrary times
class Test {
constructor() {
this.scrollView = {
flash: () => {
console.log(this);
},
doSomethingElse: () => {
console.log('*evil laugh*');
this.scrollView = null;
},
@deecewan
deecewan / split-var-declarations.js
Created August 1, 2018 04:50
A jscodeshift codemod designed to split combined var declarations into multiple declarations
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
return j(file.source)
.find(j.VariableDeclaration)
.filter(d => d.value.declarations.length > 1)
.forEach(path => {
console.log(path)
const newDeclarations = path.value.declarations.map(dec =>
j.variableDeclaration(path.value.kind, [
@deecewan
deecewan / trello-update.js
Created July 26, 2018 14:44
Some stuff to update the uni trello boards I use.
// this runs every time i get to the page. it updates the list of weeks, puts the old weeks at the bottom,
// and adds a label to this week. It runs using TamperMonkey
(async () => {
const promisify = fn => (...args) => new Promise((resolve, reject) => {
fn(...args, resolve, reject);
});
// go to https://trello.com/app-key for the key
const token = '<ENTER KEY HERE>';
const jquery = await import('https://code.jquery.com/jquery-3.3.1.min.js');
@deecewan
deecewan / generate-icons.sh
Last active April 27, 2018 01:31
Create icons for different flavours in a react native project. Uses bash because macOS comes with it
#!/usr/bin/env bash
typeset -a FLAVORS
####
# This creates icons in all the necessary sizes for a react native project
# To use, simply set the variables after this block
# Note, this expects your standard icon to be named `icon.png`, and
# all flavor icons to be named `icon_<flavor>.png`. For example,
# `icon_dogfood.png` and `icon_nightly.png`
@deecewan
deecewan / with_amazon_keys.zsh
Created March 27, 2018 01:42
Select amazon api keys to run a command with from your ~/.aws/credentials file.
function with_amazon_keys() {
local chosen_profile=$1
if [ $# -gt 0 ]; then
shift;
fi;
local AWS_CREDENTIAL_LOCATION="$HOME/.aws/credentials"
local old_ifs="$IFS"
local IFS=$'\n'
local aws_credentials=("${(@f)$(cat $AWS_CREDENTIAL_LOCATION)}")
@deecewan
deecewan / errors.sh
Created February 1, 2018 06:44
Flow errors from redux-persist
Error: node_modules/redux-persist/es/persistStore.js.flow:67
67: persistor.purge = () => {
^^^^^ property `purge`. Property not found in
67: persistor.purge = () => {
^^^^^^^^^ object type
Error: node_modules/redux-persist/es/persistStore.js.flow:78
78: persistor.flush = () => {
^^^^^ property `flush`. Property not found in
78: persistor.flush = () => {
function doSomething() {
myVar = 3;
if (someCondition) {
myVar = 4;
}
}
let myVar = 1;
function deleteIfBad() {
if (myVar > 1) {
deleteProductionDatabase();
}
}