Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Document</title>
</head>
<body>
<div class="controls">
<div class="left">
<div id="playButton" class="button">
@Sh4yy
Sh4yy / clx.go
Created April 25, 2024 20:39
Generate CLI commands for common tasks.
package main
import (
"context"
"errors"
"fmt"
"io"
"log"
"os"
"runtime"
@banaslee
banaslee / XGH - en.txt
Last active April 26, 2024 04:46
eXtreme Go-Horse Process
eXtreme Go Horse (XGH) Process
Source: http://gohorseprocess.wordpress.com
1. I think therefore it's not XGH.
In XGH you don't think, you do the first thing that comes to your mind. There's not a second option as the first one is faster.
2. There are 3 ways of solving a problem: the right way, the wrong way and the XGH way which is exactly like the wrong one but faster.
XGH is faster than any development process you know (see Axiom 14).
@hax
hax / channel.js
Created May 13, 2020 15:12
A experimental Channel in JS
// kotlin channel: https://kotlinlang.org/docs/reference/coroutines/channels.html
// golang channel
class Channel {
constructor() {
this._s = null
this._r = null
}
send(v) {
if (this._r) {
@hax
hax / README.md
Created January 18, 2022 12:52
Experimental API

NOTE: This proposal was mainly written 2 years ago, many examples may already outdated, but the whole idea should still apply.

Experimental API

Motivation

I have a dream, that the new JS APIs could be developed like good open source libraries, have reference implementation maintained by champions and volunteers in the whole lifecycle from stage 1 to stage 4, clearly marked as "experimental feature" not "polyfill", follow semver, and available in all platforms (all engines, browsers and node.js) automatically, accept issues and PRs in official github repo, can have branches to test new ideas, allow forks and healthy competition...

Problems

Array (a collection of elements accessed by integer indices) is probably one of the most commonly used data structures by programmers, and slice is one of the most commonly used array methods. (This statistic also indicates that splice seems to be used more than we thought.)

Method Search Results
push more than 2913780 results from 110260 repositories
forEach 1303701 results from 94472 repositories
slice 743508 results from 76749 repositories
indexOf 621518 re
@hax
hax / index.js
Created September 1, 2022 10:57
JS trick to mimic C# obj.onevent += delegate
const HandlerID = Symbol()
export function defineEvent(obj, name) {
const handlers = new Set()
const fn = function () {
for (const handler of handlers) {
try {
handler()
} catch (e) {
Promise.reject(e)
@kirilkirkov
kirilkirkov / gist:d333f77df4f33d76bd5b
Created February 24, 2016 09:11
php fluent interface pattern $obj->method1()->method2();
<?php
class User
{
protected $name;
protected $surname;
protected $password;
public function setName($name)
{
@a7ul
a7ul / complex.diff
Created June 15, 2018 10:56
blog-on-node-addon-complex-obj
diff --git a/cppsrc/Samples/classexample.cpp b/cppsrc/Samples/classexample.cpp
index 8dfa3cc..834f7ea 100644
--- a/cppsrc/Samples/classexample.cpp
+++ b/cppsrc/Samples/classexample.cpp
@@ -22,8 +22,17 @@ ClassExample::ClassExample(const Napi::CallbackInfo& info) : Napi::ObjectWrap<Cl
Napi::HandleScope scope(env);
int length = info.Length();
- if (length != 1 || !info[0].IsNumber()) {
- Napi::TypeError::New(env, "Number expected").ThrowAsJavaScriptException();