Skip to content

Instantly share code, notes, and snippets.

@boxofrox
boxofrox / wayward-generator-example.js
Created April 14, 2013 20:37
Simple example demonstrating the definition and use of a simple generator function.
/* generator
*
* takes a chance value, C, an array of objects, and returns a Generator
* function that computes a random value, R. if R < C the Generator returns
* nothing, else the Generator returns a random item from the array of
* objects.
*
* params:
* chance: floating point value between [0,1].
* objs: array of objects to select from.
@boxofrox
boxofrox / example-lazy-stats-accessor.js
Last active December 16, 2015 09:39
Lazy stats accessor. Only recomputes value when necessary, but requires managing flags to avoid stale cache.
// need a static local variable here to ensure all new stats have unique'ish ids.
// stacking the same modifier is not possible. create a new object of the same modifier in order
// to apply the same effect twice.
var StatModifier = (function () {
var idCounter = 0;
return Base.extends({
id: 0,
name: '',
affects: '',
@boxofrox
boxofrox / gist:ec6132f3ecd658c5fe24
Created May 29, 2015 16:32
Meteor template error with #each var in array

main.coffee

if Meteor.isClient
  Session.setDefault('app.ports', ['test'])

  Template.content.helpers(
    app: ->
      ports: Session.get('app.ports')
@boxofrox
boxofrox / publish-counts-issue-35.js
Last active August 29, 2015 14:27
Reactive publish-counts with computation example
// don't leak observes in Meteor.publish callback. Define only one instance for server of buyer and distributor ids for reactive counts.
var buyers = new Meteor.Collection(null);
var distributors = new Meteor.Collection(null);
var observer = {
added: function (doc) {
if (isBuyer(doc))
buyers.insert({ _id: doc._id });
else if (isDistrib(doc))
@boxofrox
boxofrox / .gitignore
Last active October 15, 2015 00:14
Meteor Test: find docs in collection where array field contains any value in a set.
.meteor
@boxofrox
boxofrox / NmapHeartbleed.md
Created November 17, 2015 20:03 — forked from bonsaiviking/NmapHeartbleed.md
Guide to using Nmap to scan for the Heartbleed bug.

Requirements

  1. Nmap. The script requires version 6.25 or newer. The latest version, 6.47, already includes the next 3 dependencies, so you can skip directly to the Scanning section below.
    • An easy way to get the latest Nmap release is to use Kali Linux.
    • Binary installers are available for Windows.
    • RPM installer available for Linux, or install from source.
    • .dmg installer available for Mac OS X.
  2. tls.lua. The script requires this Lua library for TLS handshaking.
  3. ssl-heartbleed.nse. This is the script itself.
const R = require('ramda');
const Future = require('ramda-fantasy').Future;
// :: Int -> [Future a b] -> Future a [b]
// number of workers :: Int
// tasks to do :: [Future a b]
const batchParallel = R.curry((N, as) => {
if (0 === as.length || N < 1) {
return Future.of([]);
}
import { __, always, call, compose, concat, cond, converge, curry, equals,
flatten, head, init, is, isEmpty, join, last, map, of, path, prop,
split, T, tail, toPairs, toString, trim, unapply } from 'ramda';
// :: String -> String
const indent = curry((level, a) => concat(' '.repeat(level), a));
// :: [String] -> String
const joinLines = join('\n');
@boxofrox
boxofrox / publish-counts-issue-83.diff
Created April 3, 2016 22:46
Alternative solution to issue-83. Tested simply to verify code works. Not tested or benchmarked under load.
commit 360527e99cbae6fc702615e9f03485210bccbc89
Author: Justin Charette <[email protected]>
Date: Sun Apr 3 18:23:45 2016 -0400
track review counts per profile and show in developer profile boxes
Signed-off-by: Justin Charette <[email protected]>
diff --git a/both/collections/reviewCounts.js b/both/collections/reviewCounts.js
new file mode 100644
@boxofrox
boxofrox / a-rbx-2.5.2-install.txt
Last active November 9, 2016 03:26
rvm install rbx-2.5.2 (2016-11-08)
⯈ pacman -Qs clang
local/clang35 3.5.2-3
C language family frontend for LLVM
⯈ pacman -Qs llvm
local/clang35 3.5.2-3
C language family frontend for LLVM
local/lib32-llvm-libs 3.9.0-1 # dep for lib32-mesa
Low Level Virtual Machine (runtime library)(32-bit)
local/llvm-libs 3.9.0-1 # dep for mesa and rust