Skip to content

Instantly share code, notes, and snippets.

Avatar
😕
​ignoring side projects

David Buchan-Swanson deecewan

😕
​ignoring side projects
View GitHub Profile
@deecewan
deecewan / prefer_rich_diffs.js
Created Oct 11, 2019
A Tampermonkey script to default to the rich diff for files in a PR if/when they exist
View prefer_rich_diffs.js
// ==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
Tampermonkey scipt to change chat windows with a keypress
View chat_changer.js
// ==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 Aug 13, 2018
This is why flow invalidates type refinements at seemingly arbitrary times
View refinement.js
class Test {
constructor() {
this.scrollView = {
flash: () => {
console.log(this);
},
doSomethingElse: () => {
console.log('*evil laugh*');
this.scrollView = null;
},
@deecewan
deecewan / split-var-declarations.js
Created Aug 1, 2018
A jscodeshift codemod designed to split combined var declarations into multiple declarations
View split-var-declarations.js
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 Jul 26, 2018
Some stuff to update the uni trello boards I use.
View trello-update.js
// 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 Apr 27, 2018
Create icons for different flavours in a react native project. Uses bash because macOS comes with it
View generate-icons.sh
#!/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 Mar 27, 2018
Select amazon api keys to run a command with from your ~/.aws/credentials file.
View with_amazon_keys.zsh
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 Feb 1, 2018
Flow errors from redux-persist
View errors.sh
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 = () => {
View new-function.js
function doSomething() {
myVar = 3;
if (someCondition) {
myVar = 4;
}
}
View declaration.js
let myVar = 1;
function deleteIfBad() {
if (myVar > 1) {
deleteProductionDatabase();
}
}
You can’t perform that action at this time.