Skip to content

Instantly share code, notes, and snippets.

View sexwithsatan's full-sized avatar

sex with satan sexwithsatan

View GitHub Profile
@georgboe
georgboe / fm2toavi.sh
Created April 12, 2017 21:31
Script to convert .fm2 files to actual video files
#!/bin/bash
# Usage: fm2toavi.sh rom.nes movie.fm2 output.mkv
if [ "$#" -ne 3 ]; then
echo "Usage: fm2toavi.sh rom.nes movie.fm2 output.mkv"
exit 1
fi
fceux \
@sergiodxa
sergiodxa / async-thread.js
Last active June 27, 2023 05:38
Use WebWorkers and promises to run sync heavy functions in a worker (process) and get the result in a promise
function asyncThread(fn, ...args) {
if (!window.Worker) throw Promise.reject(
new ReferenceError(`WebWorkers aren't available.`)
);
const fnWorker = `
self.onmessage = function(message) {
(${fn.toString()})
.apply(null, message.data)
.then(result => self.postMessage(result));
@jkrems
jkrems / generators.md
Last active February 24, 2020 19:09
Generators Are Like Arrays

In all the discussions about ES6 one thing is bugging me. I'm picking one random comment here from this io.js issue but it's something that comes up over and over again:

There's sentiment from one group that Node should have full support for Promises. While at the same time another group wants generator syntax support (e.g. var f = yield fs.stat(...)).

People keep putting generators, callbacks, co, thunks, control flow libraries, and promises into one bucket. If you read that list and you think "well, they are all kind of doing the same thing", then this is to you.

@tracker1
tracker1 / 01-directory-structure.md
Last active April 20, 2025 18:24
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used