Skip to content

Instantly share code, notes, and snippets.

/**
* index.js
* July 20th 2017
*/
"use strict";
function DataViewObject() {
@sjkillen
sjkillen / bar.sjd
Created September 27, 2017 04:40
Fooland
foo
@sjkillen
sjkillen / gather.sh
Last active September 28, 2017 02:27
Calculate the unique set of prime factors for a number
#!/bin/bash
if ! [[ $1 ]]; then
exit 1
fi
echo "target,factorization,num_factors"
for t in `seq 2 $1`; do
facts=$(./primes <<< "$t")
@sjkillen
sjkillen / gist:264b64cf9d3d93d7042a218e4faabe8b
Created October 31, 2017 04:20
Hidden javascript builtin functions
(Always returns undefined function and does nothing)
a=Function.prototype
a("hello world")
(edited)
(Identity function, returns the first argument you give it)
a=Function.prototype.call.bind([][Symbol.iterator]().__proto__.__proto__[Symbol.iterator])
a("hello world") === "hello world"
class ProxyPromise extends Promise {
constructor(...args) {
super(...args);
return new Proxy(this, {
get(target, property, receiver) {
if (property in target) {
const prop = Reflect.get(target, property, receiver);
if (typeof prop === "function") {
return prop.bind(target);
} else {
@sjkillen
sjkillen / replfile.py
Created February 23, 2018 01:41
Write entire contents of file to stdout and then pipe stdin to stdout
#!/usr/bin/python3
from sys import argv
with open(argv[1]) as f:
print(f.read(), end="")
try:
while True:
print(input(), end="")
interface EventRegister<T> {
event: keyof T,
// any used here because ts is picky, doesn't make a difference
// may be able to replace with T[keyof T] in future versions
callback: {(data: any): void},
once: boolean
}
/**
* Basic callback based publish / subscribe baseclass
/*
* Spencer Killen
* CMPT 360
* Assignment 3
* Dec 5th 2016
* Library used for applying a file lock after a condition is met
*/
#include <sys/inotify.h>
#include <aio.h>