Skip to content

Instantly share code, notes, and snippets.


Brian J Brennan brianloveswords

View GitHub Profile
View altcaps.js
function altcaps(words) {
const letters = words.toString('utf8')
const methods = ['Upper', 'Lower']
var idx = 0
var midx = (Math.random() * 100)|0
var newstring = ''
var letter
for (; idx < letters.length; idx++) {
letter = letters[idx]
newstring += (letter.match(/\s/))

Milestone Badge Planning

This will be triggered whenever a user earns a badge. Also, assume all relationships for each query are fulfilled.

  1. Find related milestones, relatedMilestones: MilestoneBadges.get({ badgeId: <badgeId> })
  • Return early if there are no related milestones.
  1. Get list of user's badges, userBadges: BadgeInstances.get({ email: <userEmail> })
  2. Get the relative complement of userBadges and relatedMilestones (related milestone badges the user has not earned yet) to make set of unearnedMilestones.
  • Return early if the relative complement set is empty.
  1. Filter unearnedMilestones by eligibility for fulfillment to get eligibleMilestones
extern crate debug;
struct Point {
x: f64,
y: f64
enum Shape {
Circle(Point, f64),
Rectangle(Point, Point)
View 1.
pub fn i64_as_bytes_be(n: i64) -> Vec<u8> {
let mut vec = Vec::with_capacity(8);
vec.push(((n & 0xff00000000000000) >> 56) as u8);
vec.push(((n & 0x00ff000000000000) >> 48) as u8);
vec.push(((n & 0x0000ff0000000000) >> 40) as u8);
vec.push(((n & 0x000000ff00000000) >> 32) as u8);
vec.push(((n & 0x00000000ff000000) >> 24) as u8);
vec.push(((n & 0x0000000000ff0000) >> 16) as u8);
vec.push(((n & 0x000000000000ff00) >> 8) as u8);
vec.push(((n & 0x00000000000000ff)) as u8);
View sjw-skeleton.user.js
// ==UserScript==
// @name SJW→skeleton
// @namespace
// @include*
// @include*
// @include*
// @include*
// @include*
// @version 1
// @grant none
$(cd /tmp && curl -H "Host:" > brooklynjs.html && $(command -v open > /dev/null && which open || which xdg-open) brooklynjs.html && sleep 3 && rm brooklynjs.html)

Notes on systemd vs upstart

General notes

  • systemd is very well adopted across linux distros and is becoming the default for Debian and Ubuntu sometime in the next year.
  • Upstart is the default for Ubuntu 14.04 LTS and that’s what we currently deploy to.
    • It is not super trivial to change 14.04 LTS to use to systemd
    • It is pretty trivial to change 14.10 to use systemd, but I’m not sure we want to deploy to that.

I have two directories that look like this:

$ ls
dirA/ dirB/

$ ls dirA
bg_BG/  cs_CZ/  de_DE/  el_GR/  en_AU/  en_GB/  en_PH/  en_PL/	en_SG/  en_US/  es_AR/
es_ES/  es_MX/  fr_FR/  hu_HU/  id_ID/  it_IT/  ja_JP/  ko_KR/	ms_MY/  nl_NL/  pl_PL/
pt_BR/  pt_PT/  ro_RO/  ru_RU/  th_TH/  tr_TR/  vn_VN/  zh_CN/	zh_MY/  zh_TW/