Skip to content

Instantly share code, notes, and snippets.

View rhysd's full-sized avatar
🐕
Fixing an off-by-wan error

Linda_pp rhysd

🐕
Fixing an off-by-wan error
View GitHub Profile
@rhysd
rhysd / chained.js
Last active October 30, 2022 11:48
How to create Iterable object which chains JavaScript Iterator objects
function chained(...iterators) {
return {
[Symbol.iterator]() {
return {
next() {
if (iterators.length === 0) {
return { done: true };
}
const result = iterators[0].next();
@rhysd
rhysd / js_run.js
Last active November 27, 2019 05:05
benchmark JSON vs JS Object
const d = {
lastUpdate: 1574785732173,
entries: {
'Rust Benchmark': [
{
commit: {
author: {
email: 'lin90162@yahoo.co.jp',
name: 'rhysd',
username: 'rhysd',
; ModuleID = 'foo.c'
source_filename = "foo.c"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
; Function Attrs: noinline nounwind ssp uwtable
define i32 @main() #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
store i32 0, i32* %1, align 4
@rhysd
rhysd / pre-push
Created December 1, 2018 15:53
pre-push check script in .git/hooks for Go project
#!/bin/bash
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
@rhysd
rhysd / cmd
Created August 11, 2018 02:02
setjmp/longjmp test
emcc main.c --js-library main.js -o hello.html -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall']"
This file has been truncated, but you can view the full file.
(module
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(type $FUNCSIG$vii (func (param i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $FUNCSIG$iiiiiiii (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
#! /bin/bash
set -e
if [[ "$1" == "" ]]; then
echo "Usage: git pull-pr {PR number}" 1>&2
exit 1
fi
git fetch origin "pull/$1/head:pr-$1"
#!/usr/bin/env ruby
require 'benchmark'
puts Benchmark.measure {
s = ""
5000000.times do
s << "hey, hey, "
end
}
package main
func main() {
arr := []int{5, 4, 3, 2, 1}
l := len(arr)
for i, e := range arr[:l/2] {
j := l - 1 - i
arr[i] = arr[j]
arr[j] = e
}
type CONTINUE = 100;
type SWITCHING_PROTOCOLS = 101;
type OK = 200;
type CREATED = 201;
type ACCEPTED = 202;
type NON_AUTHORITATIVE_INFORMATION = 203;
type NO_CONTENT = 204;
type RESET_CONTENT = 205;
type PARTIAL_CONTENT = 206;
type MULTIPLE_CHOICES = 300;