Skip to content

Instantly share code, notes, and snippets.

View brianloveswords's full-sized avatar
💭
computering

Brian J Brennan brianloveswords

💭
computering
View GitHub Profile
@brianloveswords
brianloveswords / partial-package.json
Created September 18, 2017 23:01
TypeScript autobuild and copy to clipboard. Useful for developing stuff where you can't actually access the content directly in a text editor (e.g. tampermonkey)
{
"scripts": {
"build": "tsc && npm run post-build",
"watch": "tsc-watch --onSuccess 'npm run post-build'",
"post-build": "rollup build/index.js --o build/bundle.js --f iife && cat src/prelude.js build/bundle.js | (pbcopy && osascript -e 'display notification \"Script copied to clipboard\" with title \"Script Builder\"' || echo 'copied script to clipboard')"
}
}

Keybase proof

I hereby claim:

  • I am brianloveswords on github.
  • I am brianloveswords (https://keybase.io/brianloveswords) on keybase.
  • I have a public key ASBtQroGJWStLytKo1YW1Jom-wCpZdwvzrP8cn0N0auwjQo

To claim this, I am signing this object:

@brianloveswords
brianloveswords / git-obliterate
Created June 6, 2017 19:57
Obliterate a file from your git history
#!/usr/bin/env bash
file="$1"
test -z "$file" && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached '$file' --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
@brianloveswords
brianloveswords / tweet.ts
Last active March 12, 2018 16:53
Twitter API tweet type definition
/// `id` fields are purposely omitted as they not safe to use in JavaScript.
/// Twitter uses 64 bit ids and JavaScript can only safely represent 2^53-1.
/// I decided to go with `<field>?: type` instead of `<field>: type | null`
/// because of the following line in the api documentation:
///
/// “It is generally safe to consider a nulled field, an empty set, and the
/// absence of a field as the same thing”
/// https://dev.twitter.com/overview/api/tweets

Mariko is wrong about things

// The Counted uses lazy loading so make sure to scroll slowly down
// the page to the bottom before trying to run this or your count will
// be off.
let elements = Array.from(document.querySelectorAll('.record-inner .date'));
let dates = elements.map(e => new Date(e.innerHTML)).reverse();
let initialState = {
previousDate: dates.shift(),
maxDifference: 0,
count: 0,
/// <reference path="node.d.ts" />
"use strict";
const HEARTS: Array<string> =
["❤","♥","💗","💓","💕","💖","💞","💘","💛","💙","💜","💚","💝",];
const BIRTHDAY: Array<string> = ["🙌","🎂","🍰","🎈","🎉","🎁","🍕"];
const EMOJI = BIRTHDAY;
extern crate handlebars;
extern crate rustc_serialize;
use std::collections::HashMap;
use handlebars::Handlebars;
type Data = HashMap<String, String>;
struct Templatizer {
handlebars: Handlebars,
(require 'flycheck)
(flycheck-define-checker cargo-rust
"A Rust syntax checker using cargo rustc.
This syntax checker needs Rust 1.1 or newer.
See URL `http://www.rust-lang.org'."
:command ("cargo" "rustc"
"--lib"
"--" "-Z" "no-trans"
"--test")
// pre-compiled
function randomElement(array) {
var index = Math.random() * array.length | 0;
return array[index];
}
function printEmoji(emoji, num) {
if (num <= 0)
return;
process.stdout.write(randomElement(emoji));
return printEmoji(emoji, --num);