Skip to content

Instantly share code, notes, and snippets.

@ku
ku / cryptrandint.go
Created December 5, 2023 01:11
crypt/rand Int() distribution
package main
import (
"crypto/rand"
"math/big"
"os"
"github.com/aybabtme/uniplot/histogram"
)
urls = [
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201201?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201202?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201203?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201204?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201205?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201206?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201207?ts=1607320647235",
package main
import (
"fmt"
"math/rand"
"time"
)
type Barrier struct {
para chan int
@ku
ku / main.go
Last active April 7, 2021 10:19
binary CodeGeneratorRequest file generator
//
// CodeGeneratorRequest binary generator
// curl https://gist.githubusercontent.com/ku/57c4fc1c70e99e24774d88cd5be5f6e7/raw > main.go
// go build -o protoc-gen-echo main.go
// protoc --plugin=./protoc-gen-echo --echo_out=. test.pb
package main
import (
"io"
@ku
ku / dump_sf_icon_as_png.swift
Last active November 8, 2023 10:55
dump SF symbols as PNG
import UIKit
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white
@ku
ku / README.md
Last active February 14, 2018 03:27
chrome extension allows all CORS
  1. clone this gist
  2. edit "permissions" of manifest.json to fit your environment
  3. open chrome://extensions/
  4. click "Load unpacked extension..."
  5. select the directory where the files are placed
  6. chrome no longer prohibits CORS requests in permitted domains

Popsicle icon is by Lee dessert Collection | Noun Project

@ku
ku / react-native-friendly-jwt.js
Created September 1, 2017 01:14
pure json react native friendly JWT
const base64 = require('base-64')
const base64url = (s) => base64.encode(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '')
const CryptoJS = require( 'crypto-js')
const hmacSHA256 = CryptoJS.HmacSHA256
var seed = {
sub: "1234567890",
name: "John Doe",
admin: true
}
@ku
ku / bounty.html
Last active August 30, 2017 05:36
aigang
<!DOCTYPE html>
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<head>
<title>報奨金をもらう | Aigang</title>
<base href="https://bounty.aigang.network/" >
<!-- Meta -->
<meta charset="utf-8">
@ku
ku / gist:fc9205014cf5de3f815c1e19ccdaf283
Created August 5, 2017 13:17
encrypt with github public key
echo hello | openssl rsautl -encrypt -pubin -inkey <(ssh-keygen -e -m PKCS8 -f <(curl -s https://github.com/ku.keys)) \
| openssl rsautl -decrypt -inkey ~/.ssh/id_rsa
for ( tr of document.querySelectorAll('tr[class=" "]') ) {
const s = tr.querySelector('select')
if (!s) continue;
const a = tr.querySelector('a')
a.click();
var [from, to] = tr.querySelectorAll('td.td-attendance-time input')
from.value = '10:00';
to.value = '19:00';
}