Skip to content

Instantly share code, notes, and snippets.

View brianloveswords's full-sized avatar
💭
computering

Brian J Brennan brianloveswords

💭
computering
View GitHub Profile

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
const restify = require('restify')
const server = restify.createServer({
name: 'next test',
version: '1.0.0'
});
server.get('/', function (req, res, next) {
console.log('nexting')
req.whatever = Date.now()
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/))
@brianloveswords
brianloveswords / git-obliterate
Last active January 24, 2024 12:28
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
#!/bin/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
git ignore $file
git add .gitignore
git commit -m "Add $file to .gitignore"
##
## Arch Linux repository mirrorlist
## Sorted by mirror score from mirror status page
## Generated on 2013-03-01
##
## Score: 0.3, United States
Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.5, Germany
Server = http://mirror.de.leaseweb.net/archlinux/$repo/os/$arch
var http = require('http')
var count = 0
// this emulates hitting the max number of open sockets
http.globalAgent.maxSockets = 1
http.createServer(function (req, res) {
count++
(function (count) {

OpenBadger v3 planning

Core

Storage Abstraction

Badge Creation (primary issuer details, badge details)

Plugins

Multiple Issuers

setImmediate(function () {
console.log('immediate')
})
setTimeout(function () {
console.log('timeout 0')
}, 0)
process.nextTick(function () {
console.log('next tick')
})

Preface

So this was inspired both by @maxogden and @mcollina's talks at nodeconf.eu 2013. Max spoke about the power (and fun!) of understanding & manipulating with binary data in JavaScript, and Matteo pointed to a protocol called MQTT that manages to a flexible, featureful protocol with only a 2 byte overhead. In looking how they do that (http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html) I noticed they make rich use of the individual bits of those bytes. I realized that off the top of my head I didn't know how I would parse out that information and JavaScript, so I set up about to experimenting to see if I could figure it out without looking up the answer. After figuring it out I wrote a little mini monster protocol & tutorial to maybe help others understand this neat technique!

Now, Let's describe a whole monster in just one byte.

First we need to define the semantics of our bit field. As a reminder, a byte is m

@brianloveswords
brianloveswords / eff-you-region-lock.md
Last active December 22, 2015 15:08
Defeating region lock

Prerequisites

  • Somewhat modern version of OpenSSH
  • Server you have SSH access to in the region you want to stream from.

Bummed about region lock? Start up your terminal and do this:

$ ssh -N -D 9999 yourserver.com