Skip to content

Instantly share code, notes, and snippets.

@eush77
eush77 / bitsquest-bounce.js
Created June 26, 2014 10:49
Helper function for Bit's Quest (bitsquest.bitbucket.org) that launches callbacks in a sequence
var phase = 0;
var bounce = (function () {
var nextPhaseToAssign = 0;
var opposite = {
top: 'bottom',
left: 'right',
bottom: 'top',
right: 'left'
};
@eush77
eush77 / decode.js
Created July 1, 2014 19:21
Small script that renames files with percent-encoded names (sometimes Curl downloads them)
#!/usr/bin/nodejs
var fs = require('fs');
var util = require('util');
var decodeFiles = function(files) {
util.puts('');
var message = '\rRenaming... ';
var count = files.length;
files.forEach(function(file, index) {
@eush77
eush77 / eratostream.js
Created September 18, 2014 05:41
Stream of prime numbers in vanilla Node.JS
// SICP 3.5.2: https://sarabander.github.io/sicp/html/3_002e5.xhtml#g_t3_002e5_002e2
// Node v0.10.31
var stream = require('stream');
var getPrimes = function (count) {
integers(2)
.pipe(primes())
.pipe(take(count))
@eush77
eush77 / eratostream.hs
Last active August 29, 2015 14:11
Stream of prime numbers, this time in Haskell
-- SICP 3.5.2: https://sarabander.github.io/sicp/html/3_002e5.xhtml#g_t3_002e5_002e2
sieve :: Integral a => [a] -> [a]
sieve (n : ns) = n : sieve (filter (\x -> x `mod` n /= 0) ns)
primes :: [Integer]
primes = sieve [2..]
main :: IO ()
main = let ns = take 100 primes
@eush77
eush77 / quotes.md
Last active September 8, 2015 17:13
Selected quotes

James Halliday, “How to not write big apps!”, NodeJS Conference, Dublin 2012 [[youtube]][substack-big-apps]

  • "Always Be Npm Publishing, because whenever you npm-publish or put something on GitHub you don't have to think about it anymore, it [becomes a] feature of the landscape."
  • "The secret to not writing a big app is not to have written a big app in the first place."

James Halliday, “Code Collage”, JSConf EU, Berlin 2012 [[youtube]][substack-code-collage]

  • "The best thing that can be said of software is that it is too small."

Isaac Z. Schlueter, “Making Make Make Sense”, npm Inc. Demo Day, 2015-01-16 [[youtube]][isaacs-make]

@eush77
eush77 / eratostream.clj
Created March 7, 2015 11:25
Stream of prime numbers, in Clojure
; SICP 3.5.2: https://sarabander.github.io/sicp/html/3_002e5.xhtml#g_t3_002e5_002e2
(defn sieve [[x & xs]]
(cons x (lazy-seq (sieve (remove #(zero? (mod % x)) xs)))))
(def primes (sieve (drop 2 (range))))
(println (apply str (interpose ", " (concat (take 100 primes) ["..."]))))
@eush77
eush77 / eratostream.es6
Last active August 29, 2015 14:16
Stream of prime numbers, in JavaScript ES6
// SICP 3.5.2: https://sarabander.github.io/sicp/html/3_002e5.xhtml#g_t3_002e5_002e2
const sieve = function* (sequence) {
const { value: first, done } = sequence.next();
if (done) return;
yield first;
yield* sieve(function* () {
for (let value of sequence) {
if (value % first) {
@eush77
eush77 / quine.js
Created May 31, 2015 19:56
Quine in JS
(function q() {
console.log('(' + q + '());');
}());
@eush77
eush77 / break.gdb
Last active November 19, 2015 13:29
Gdb breakfile with breakpoint commands and use of the Python API — for future reference
delete
break ic.cc:702 if ((String*)*name)->length() == 1
break full-codegen-x64.cc:1459 if !strcmp(var->name()->ToAsciiArray(), "a")
break parser.cc:1020
condition $bpnum shared_info->end_position() - shared_info->start_position() == 13 and shared_info->is_compiled() and !shared_info->has_deoptimization_support\
()
@eush77
eush77 / invert.css
Last active September 12, 2015 08:42
Proper color inversion for Firefox
/**
* Copied from https://addons.mozilla.org/en-US/firefox/addon/black-background-white-text/
*/
html,
img:not(.mwe-math-fallback-image-inline),
embed[type="application/x-shockwave-flash"],
object[type="application/x-shockwave-flash"],
video
{
filter: invert(100%) hue-rotate(180deg) !important;