Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ohkubo KOHEI kuboon

🏠
Working from home
View GitHub Profile
View mtx.c
#include <stdio.h>
#include <assert.h>
#define N 16
#define K 8
#include "global.h"
#include "chash.c"
#include "inv_mat.c"
typedef struct {
View keybase.md

Keybase proof

I hereby claim:

  • I am kuboon on github.
  • I am kuboon (https://keybase.io/kuboon) on keybase.
  • I have a public key ASB-DFiIjV4i7r3896Wm4qQEdU_9djhLMFZ3j2t1xZCcgQo

To claim this, I am signing this object:

@kuboon
kuboon / install_gcloud.sh
Created Oct 6, 2020
install gcloud on Ubuntu
View install_gcloud.sh
#!/bin/env sh
sudo apt install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt update && sudo apt install google-cloud-sdk
@kuboon
kuboon / getSelectionWithAlt.ts
Last active Oct 10, 2020
document.getSelection with img.alt text
View getSelectionWithAlt.ts
function isImg(node: Node):node is HTMLImageElement{
return node.nodeName==='IMG'
}
function selectionToFragment(){
const s = document.getSelection()
const r = s!.getRangeAt(0)
return r.cloneContents()
}
function getTextFromFragment(f: DocumentFragment) {
const walker = document.createTreeWalker(f, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
@kuboon
kuboon / main.py
Created Sep 17, 2020
HTML based GUI app with python flask
View main.py
from flask import Flask,request
app = Flask(__name__)
@app.route('/')
def index():
return "<form method='post' action='form'><input name='val'><button type='submit'>send</button></form>"
@app.route('/form', methods=['POST'])
def form():
View drive.ts
const res = await drive.permissions.create({
fileId,
requestBody: {
role: 'writer',
type: 'user',
emailAddress: 'ohkubo@heartrails.com'
}
})
View jsonComp.ts
export function comp(x: any, y: any): boolean {
if (typeof x === 'object') {
const keys = Object.keys(x)
if (keys.length !== Object.keys(y).length) return false
return keys.every(k=>comp(x[k], y[k]))
}
return x === y
}
const a = {a:1,b:2,c:{a:1,b:3}}
@kuboon
kuboon / enc_dec.ts
Last active Jun 12, 2020
Typescript nodejs stdlib enc/dec sample
View enc_dec.ts
import * as crypto from 'crypto'
import assert from 'assert'
const ivKey = 'randomString1-fah3f;aklajr'
const initialVec = Buffer.alloc(16, 0)
crypto
.createHash('sha256')
.update(ivKey)
.digest().copy(initialVec)
@kuboon
kuboon / sample.ts
Created Apr 22, 2020
Typescript: constructor with named arguments
View sample.ts
class ConstructorArgs {
namespace: string[] = ["default", "values"]
}
class Base extends ConstructorArgs {
constructor(opts: ConstructorArgs = new ConstructorArgs) {
super()
Object.assign(this, opts)
}
}
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dumber Gist</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<base href="/">
</head>
<!--
Dumber Gist uses dumber bundler, the default bundle file
You can’t perform that action at this time.