Skip to content

Instantly share code, notes, and snippets.

@jinroh
jinroh / README.md
Last active March 26, 2024 07:54
Fourier series visualisation with d3.js.

From Wikipedia:

In mathematics, a Fourier series decomposes periodic functions or periodic signals into the sum of a (possibly infinite) set of simple oscillating functions, namely sines and cosines (or complex exponentials).

Use the bottom right form to change the visualized serie.

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/DataDog/datadog-agent/pkg/compliance/k8sconfig/k8s-node-config",
"properties": {
"version": {
"type": "string"
},
"managedEnvironment": {
"$ref": "#/$defs/K8sManagedEnvConfig"
},
@jinroh
jinroh / index.html
Last active September 13, 2019 10:26
Image intensity histogram
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
body {
font: 10px sans-serif;
}
#main {
@jinroh
jinroh / random_string.go
Last active January 22, 2018 07:46
Generate random string in Go
BenchmarkRandomStringA-4 2000000 702 ns/op
BenchmarkRandomStringB-4 10000000 120 ns/op
BenchmarkRandomStringC-4 20000000 115 ns/op
BenchmarkRandomStringD-4 10000000 121 ns/op
eventsource
go-eventsource
client/client
@jinroh
jinroh / await.js
Created April 21, 2013 16:09 — forked from domenic/await.js
Await and yield
// Let `doAjax`, `fadeIn`, `fadeOut`, and `delay` be promise-returning functions.
// In all the following examples, `example` is meant to return a promise that is fulfilled when
// all operations are completed, or rejected if any of the steps fail.
// ES5
function example() {
return doAjax("data.json").then(function (data) {
document.getElementById("data").innerText = data;
@jinroh
jinroh / ecma5_on_v8.js
Created December 2, 2012 19:20 — forked from Jxck/ecma5_on_v8.js
ECMA 5 Features in V8
/**
* The sample usage of ECMA 5 Mozilla Features Implemented in V8
* https://github.com/joyent/node/wiki/ECMA-5-Mozilla-Features-Implemented-in-V8
* You can use thease new feature of ECMA5 on Node.js as you like.
* because there is no IE :)
* Order is deferent form original wiki.
* Sources are Checked on Node.js v0.5.0(unstable), v0.4.9(stable)
*
* you can execute this file.
* $ node ecma5_on_v8.js
@jinroh
jinroh / gist:2730863
Created May 19, 2012 13:31
Iterative Deferred with finish conditions...and timeout
var lookup = function(target) {
var send = function() { /* ... */ },
iterative = new IterativeFind(),
init = new XORSortedPeerArray().relativeNodeID(target),
staled = false;
function map(peer) {
var rpc = new FindNodeRPC(peer, this._target);
send(rpc);
return rpc;
@jinroh
jinroh / gist:1919161
Last active October 1, 2015 04:28
Markit!
#!/usr/bin/env ruby
require 'rubygems'
require 'redcarpet'
require 'albino'
class SyntaxRenderer < Redcarpet::Render::HTML
def initialize(options)
super options
@style = options[:style]
@jinroh
jinroh / gist:1555907
Last active September 29, 2015 05:57
Kademlia Iterative Find (v1)
# in this algorithm, all notions of *sorting*, *close* or *distance*
# are relative to the XOR distance with the target ID
# as defined in the Kademlia spec
- iterative find (target ID) ->
# INITIALIZATIONS
HeardOf <- XOR Sorted Array of peers
initialized with the 50 (or less) closest peers we know from the our routing table
Reached <- XOR Sorted Array of peers
Queried <- Array of peers