Skip to content

Instantly share code, notes, and snippets.

View ORESoftware's full-sized avatar
🏐
Focusing

Alexander Mills ORESoftware

🏐
Focusing
View GitHub Profile
@dfkaye
dfkaye / import-scripts-proposal.md
Last active April 9, 2017 14:46
importScripts boilerplate pattern proposal alternatives for javascript

"JavaScript doesn't need more features; it just needs a couple of small things fixed" - Ryan Dahl

The CommonJS and AMD module syntaxes are unfriendly to each other, requiring boilerplate everywhere, which UMD tries to solve with more boilerplate.

The ES6 module syntax adds new keywords in strict mode, that then depend on a sharply modified cross-origin requests shims, and internal module management. An ES6 Module Transpiler aims to solve the not-yet-supporting environments problem with a source transformation step.

We don't need more syntax like imports x from 'x.js'. We don't need a module keyword that will break QUnit module() or Node.js modules.

@thinkerbot
thinkerbot / multiple_writers
Created September 1, 2013 18:39
Demonstrates that multiple writers to a single fifo often get inputs interleaved, regardless of sync.
#!/bin/bash
# 8... always?
mkfifo fifo
ruby -e '100000.times {|i| puts "a"}' > fifo &
ruby -e '100000.times {|i| puts "b"}' > fifo &
ruby -e '100000.times {|i| puts "c"}' > fifo &
ruby -e '100000.times {|i| puts "d"}' > fifo &
ruby -e '100000.times {|i| puts "e"}' > fifo &
ruby -e '100000.times {|i| puts "f"}' > fifo &
ruby -e '100000.times {|i| puts "g"}' > fifo &
@Boerworz
Boerworz / main.go
Last active October 10, 2023 09:14
Capturing the HTTP status code from http.ResponseWriter
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
// We need to cast handleRoot to a http.HandlerFunc since wrapHandlerWithLogging
@Xaekai
Xaekai / ipc.example.js
Created July 11, 2016 18:12
Example of Interprocess communication in Node.js through a UNIX domain socket
/*
**
** Example of Interprocess communication in Node.js through a UNIX domain socket
**
** Usage:
** server> MODE=server node ipc.example.js
** client> MODE=client node ipc.example.js
**
*/
@ORESoftware
ORESoftware / async-constructor.js
Last active January 14, 2017 03:53
An asynchronous constructor pattern
// asynchronous constructor example,
// like always do not explictly return anything from the constructor
function Queue(){
this.ready = false;
let callable = true;
let ee = new EE(); // new event emitter
// import opq
const Queue = require('opq');
// below we create a new client to the queue,
// and create the queue on the filesystem if it does
// not exist. the port is used by Live-Mutex;
// fp is our queue filepath
const q = new Queue({
const Rx = require('rxjs');
console.log(1);
new Promise(function(resolve,reject){
console.log(2);
resolve();
});
@ORESoftware
ORESoftware / obs-vs-promises-resolution.js
Last active January 14, 2017 04:21
Async or sync resolution?
console.log(1);
new Promise(function(resolve,reject){
console.log(2);
resolve();
}).then(function(val){
console.log(3);
});
@ORESoftware
ORESoftware / stringifiable.ts
Last active July 8, 2018 22:48
stringifiable type with TS
export type Stringifiable = object | string | boolean | number | null;
export const stdMarker = 'gfy';
export const getJSONCanonical = function (v: Stringifiable, marker?: string) {
marker = marker || stdMarker;
@ORESoftware
ORESoftware / domain.md
Created December 16, 2018 21:19
Simple use cases for Node.js domain module

First run this code:

const exec = () => {
   setTimeout(() => {
      throw 'nothing can catch this, except domains';
   },10);
};