This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* iterateParams() { | |
for (const x of ["a", "b", "c"]) { | |
for (const i of [1, 2, 3]) { | |
yield { x, i }; | |
} | |
} | |
} | |
for (const p of iterateParams()) { | |
console.log(p); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sys/time.h> | |
#include <time.h> | |
int main() { | |
printf("gettmeofday:\n"); | |
for (int i = 0; i < 10; i++) { | |
struct timeval tv1, tv2; | |
gettimeofday(&tv1, NULL); | |
gettimeofday(&tv2, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <errno.h> | |
#include <string.h> | |
int main() { | |
char cmdline[256]; | |
char proc_file[256]; | |
snprintf(proc_file, sizeof(proc_file), "/proc/%d/cmdline", getpid()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: use asroot; # run it as root | |
package asroot; | |
use strict; | |
use warnings; | |
# TODO: inherits @INC | |
exec "sudo", $^X, $0, @ARGV if $< != 0; | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/config/webpack.config.js b/config/webpack.config.js | |
index 601977b04..63866d814 100644 | |
--- a/config/webpack.config.js | |
+++ b/config/webpack.config.js | |
@@ -37,11 +37,16 @@ const publicPath = (() => { | |
const DAY_MS = 24 * 60 * 60 * 1000; | |
const ASSET_EXPIRED_TIME_MS = Date.now() - 14 * DAY_MS; // 14 days ago | |
+// filter core-js modules instead of just using "core-js" to reduce bundle sizes | |
+const coreJsModules = require("core-js-compat")({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
extends: [ | |
// https://eslint.org/docs/rules/ | |
"eslint:recommended", | |
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json | |
"plugin:@typescript-eslint/recommended", | |
// https://prettier.io/docs/en/eslint.html | |
"plugin:prettier/recommended", | |
// https://github.com/yannickcr/eslint-plugin-react | |
"plugin:react/recommended", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: use the last segment of the result CSV | |
/* eslint-disable no-console */ | |
import { utf8EncodeJs, utf8Count, utf8DecodeJs, utf8DecodeTD } from "../src/utils/utf8"; | |
import { utf8DecodeWasm } from "../src/wasmFunctions"; | |
// @ts-ignore | |
import Benchmark from "benchmark"; | |
for (const baseStr of ["A"]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const assert = require("assert"); | |
const jsonBuffer = fs.readFileSync("./schema.json"); | |
const object = JSON.parse(jsonBuffer.toString()); | |
const jsonParseExpr = `(JSON.parse(${JSON.stringify(JSON.stringify(object))}))`; | |
const objectLiteralExpr = `(${JSON.stringify(object)})`; | |
const N = 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for Rails v5.2 + msgpack-ruby v1.3 | |
MessagePack::DefaultFactory.register_type( | |
MessagePack::Timestamp::TYPE, | |
ActiveSupport::TimeWithZone, | |
packer: -> (time) do | |
MessagePack::Timestamp.to_msgpack_ext(time.tv_sec, time.tv_nsec) | |
end, | |
unpacker: -> (payload) do | |
tv = MessagePack::Timestamp.from_msgpack_ext(payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Experimental `push(...bytes)`-able buffer | |
// Unfortunately, it is always slower than Array<number>. | |
export class MutableBuffer { | |
private length = 0; | |
private buffer = new Uint8Array(32); | |
push(...bytes: ReadonlyArray<number>): void { | |
const newLength = this.length + bytes.length; |