Skip to content

Instantly share code, notes, and snippets.

View lykkin's full-sized avatar
🐄
Moo

Bryan Clement lykkin

🐄
Moo
View GitHub Profile
@lykkin
lykkin / counter.js
Last active February 16, 2016 21:26
messing around with asts
module.exports = {
counter: {},
count: function count(key) {
if (this.counter[key] === undefined) this.counter[key] = 0
this.counter[key]++
},
output: function output() {
for (var key in this.counter) {
console.log(key + ' was called ' + this.counter[key] + ' times')
}
@lykkin
lykkin / stuff.js
Last active February 11, 2016 22:24
async stuff
function joinCalls(doneAfter, callback) {
var counter = 0
return function wrapped() {
if (++counter === doneAfter) callback()
}
}
function joinCallsSingleValue(doneAfter, joinValuesFn, callback) {
var counter = 0
var result = null
@lykkin
lykkin / flow.js
Last active December 22, 2015 19:21
//fields have directions associated with their elements
//2d arrays of vectors
function makeBlankField(x, y) {
var map = []
for (var i = 0; i < y; i++) {
var row = []
for (var j = 0; j < x; j++) {
row.push({
x: 0,
y: 0
@lykkin
lykkin / lcs.js
Last active December 17, 2015 05:47
diff stuff
function createMatrix(m, n) {
var res = []
for (var i = 0; i < m; i++){
var row = []
for (var j = 0; j < n; j++) {
row.push({
length: 0,
sequences: []
})
}
hammer () {
if [ -z "$1" ]
then
echo "an address is required for hammering"
else
echo "hammering ${1}";
yes ${1} | xargs curl -s > /dev/null;
fi
}
@lykkin
lykkin / output
Last active November 17, 2015 03:41
prime sums
bclement:primes bclement$ gcc -O666 primes.c
bclement:primes bclement$ time ./a.out
There is no sum for 0!
There is no sum for 1!
There is no sum for 2!
There is no sum for 3!
There is no sum for 4!
There is no sum for 5!
There is no sum for 6!
There is no sum for 7!
# max subsequence sum
def max_sub_value(li):
current_max = 0
total_max = 0
for x in li:
current_max = max(current_max + x, 0)
total_max = max(current_max, total_max)
return total_max
print max_sub_value([1, 2, 3, -4, 5])
@lykkin
lykkin / boxes.js
Created September 22, 2015 17:14
wiggling boxes
var WIDTH = window.innerWidth - 20,
HEIGHT = window.innerHeight - 20;
var VIEW_ANGLE = 45,
ASPECT = WIDTH/HEIGHT,
NEAR = 0.1,
FAR = 10000;
var camera =
new THREE.PerspectiveCamera(
@lykkin
lykkin / goto.js
Created September 4, 2015 23:07
no worky
function generateFunctions() {
return function () {
break bad;
}
bad: console.log("I'm alive!")
}
generateFunctions()()
(function inject(deps){
with (deps) {
return function (output){
print(output)
}
}
})({print:console.log})(1)