Skip to content

Instantly share code, notes, and snippets.

View ShigekiKarita's full-sized avatar
🌴
I may be slow to respond.

Shigeki Karita ShigekiKarita

🌴
I may be slow to respond.
View GitHub Profile
#!/usr/bin/env python
# available: https://github.com/ShigekiKarita/practice/blob/master/PH_6-2.py
B = [0.6961663, 0.4079426, 0.8974794]
wavelength = [0.0684043, 0.1162414, 9.896161] # micro-meter
c = 29.9792458 * 10 ** 8 * 10 ** 6 # micro-meter
pi = 3.141592653589793
def n(x):
sigma = 0.
@ShigekiKarita
ShigekiKarita / circuit.v
Created June 11, 2014 06:08
How to test verilog circuit
/* HOW TO USE
iverilog -o circuit circuit.v
vvp circuit
gtkwave circuit.vcd
*/
module CIRCUIT (x, clk, z) ;
@ShigekiKarita
ShigekiKarita / tensorAdd.js
Last active August 29, 2015 14:03
JavaScriptで多次元配列の和、関数型プログラミング?
function isNumber(value)
{
return typeof value == 'number';
}
function tensorAdd(lhs, rhs)
{
return lhs.map
(
function(value, index)
#!/usr/bin/env python
# -*- coding: utf-8 -*-*
import matplotlib.pyplot as plt
import scipy.interpolate as intp
import numpy as np
# <σν> データセット
x = [1, 10, 10**2, 10**3]
y = [10**-26.5, 10**-22, 10**-21.2, 10**-21.8]
@ShigekiKarita
ShigekiKarita / fibs.lisp
Last active August 29, 2015 14:04
How to get 10th Fibonacci number in Common Lisp
;; recur
(defun fib (i &optional (a 1) (b 0))
(if (= i 1)
a
(fib (1- i) (+ a b) a)))
(fib 10)
;; do macro
(do ((i 1 (1+ i))
(a 0 b)
@ShigekiKarita
ShigekiKarita / stopwatch.js
Created July 25, 2014 11:44
simple stopwatch in JavaScript 1.8
// for Firefox 31
const time = (process, n=1) =>
{
let total = 0.0;
for (let i = 0; i < n; ++i)
{
const start = window.performance.now();
process();
const elapsed = window.performance.now() - start;
@ShigekiKarita
ShigekiKarita / js_strategy.markdown
Created July 25, 2014 12:31
Evaluation strategy in JavaScript

簡単な計測用の関数が作りたかった

const loop = _=> loop();    // stack-overflow
const one = _ => 1;

one(loop());                // -> "too much recursion" 
one(_=> loop());            // -> 1
@ShigekiKarita
ShigekiKarita / memo.js
Last active August 29, 2015 14:04
Memoize in Javacript
// for firefox31
const memoize = func =>
{
let memo = {};
return _ =>
{
if (!(arguments in memo))
{
memo[arguments] = func.apply(this, arguments);
}
@ShigekiKarita
ShigekiKarita / quicksort.js
Last active August 29, 2015 14:04
JavaScriptのリスト内包表記が括弧悪い
// for firefox31
const quicksort = (array) =>
{
if (array.length == 0) return [];
const head = array[0];
const rest = array.slice(1);
const small = [i for each (i in rest) if (head >= i)]; //rest.filter(a => head >= a);
const large = [i for each (i in rest) if (head < i)]; //rest.filter(a => head < a);
@ShigekiKarita
ShigekiKarita / corlor_stdout.cpp
Created August 9, 2014 09:36
corlor_stdout.cpp
#include <iostream>
// kaki sute module
namespace ksm
{
enum class colors : std::uint8_t
{
black, red, green, yellow, blue, magenta, cyan, white, none
};