Skip to content

Instantly share code, notes, and snippets.

View ognis1205's full-sized avatar
🐈‍⬛

Shingo OKAWA ognis1205

🐈‍⬛
View GitHub Profile
@ognis1205
ognis1205 / walkers-algorithm-with-canvas.js.html
Last active October 27, 2020 01:00
Javascript Implementation of Walkers Algorithm
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=Shift_JIS">
<title>TEST</title>
</head>
<body>
<div id="example-input">
<div>
<div>
<ul>
@ognis1205
ognis1205 / hanoi.scala
Last active August 29, 2015 14:28
Scala Metaprogrammatic Hanoi's Tower Solver
object TowerOfHanoi {
import scala.reflect.Manifest
def name(manifest:Manifest[_]):String = {
manifest.erasure.getName
}
trait NaturalNumber
final class Zero extends NaturalNumber
final class Successor[Previous<:NaturalNumber] extends NaturalNumber
@ognis1205
ognis1205 / kullback_leibler.py
Last active January 11, 2023 09:27
Calculate Kullback-Leibler Divergence of Given Corpus
import numpy
import sys
import scipy.stats as stats
import matplotlib.pyplot as plotter
from gensim import corpora, models, similarities, matutils
# Defines dictionary from the specified corpus.
dictionary = corpora.Dictionary(
line.lower().split() for line in open('corpus_train.txt', 'rb')
@ognis1205
ognis1205 / simple_debug.cc
Last active November 28, 2020 03:12
Simple Debugging Macros for C++11.
#include <iostream>
#include <set>
#include <vector>
using namespace std;
/* IO Helper Functions. */
struct has_begin_end_empty {
template<typename T>
static auto check(T&& t) -> decltype(t.begin(), t.end(), t.empty(), true_type {});
@ognis1205
ognis1205 / PoC.cc
Last active November 28, 2020 20:48
PoC Implementation of Boost.Test-Like Test Suite Hook Mechanism.
#include <iostream>
#include <list>
using namespace std;
// |
// | Start of Boost.Test Header.
// v
using Invoker = void (*)();
@ognis1205
ognis1205 / LabColorspace.cginc
Created April 12, 2022 00:53 — forked from mattatz/LabColorspace.cginc
Conversion between RGB and LAB colorspace shader for Unity.
#ifndef __LAB_COLORSPACE__
#define __LAB_COLORSPACE__
/*
* Conversion between RGB and LAB colorspace.
* Import from flowabs glsl program : https://code.google.com/p/flowabs/source/browse/glsl/?r=f36cbdcf7790a28d90f09e2cf89ec9a64911f138
*/
float3 rgb2xyz( float3 c ) {
float3 tmp;
const PENDING = Symbol('PENDING');
const FULFILLED = Symbol('FULFILLED');
const REJECTED = Symbol('REJECTED');
const exec = (f, resolve, reject) => {
let isRejected = false;
try {
f(
import sys
from io import StringIO
from re import split
from textwrap import dedent
from traceback import format_exc
class UserInput:
def __init__(self, text=None):
self._io = StringIO(text) if text else sys.stdin
<!-- reset.css destyle -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/destyle.css@1.0.15/destyle.css"
/>
<!-- reset.css modern-css-reset -->
<link
rel="stylesheet"
href="https://unpkg.com/modern-css-reset/dist/reset.min.css"
/>