#!/usr/bin/env bash
set +e;
/* | |
** | |
** 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 | |
** | |
*/ |
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func main() { | |
// We need to cast handleRoot to a http.HandlerFunc since wrapHandlerWithLogging |
#!/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 & |
First run this code:
const exec = () => {
setTimeout(() => {
throw 'nothing can catch this, except domains';
},10);
};
No official CS education but I learned about readers-writer locks after implementing a mutex library. I happened to come across a real-world use case that I would need this for.
Say we have many people signing up to take a class, their payment (through Stripe, or whatever) might be in flight. And imagine the teacher cancels the class, which would trigger a refund event.
Without proper locking, the refund might fail to execute for those students whose payments are in flight at the time of the class cancelation.
export type Stringifiable = object | string | boolean | number | null; | |
export const stdMarker = 'gfy'; | |
export const getJSONCanonical = function (v: Stringifiable, marker?: string) { | |
marker = marker || stdMarker; |
"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.
console.log(1); | |
new Promise(function(resolve,reject){ | |
console.log(2); | |
resolve(); | |
}).then(function(val){ | |
console.log(3); | |
}); |
const Rx = require('rxjs'); | |
console.log(1); | |
new Promise(function(resolve,reject){ | |
console.log(2); | |
resolve(); | |
}); |