Skip to content

Instantly share code, notes, and snippets.

View sin-to-jin's full-sized avatar
🏠
Working from home

sin sin-to-jin

🏠
Working from home
  • ExaWizards
  • Japan
  • 22:53 (UTC +09:00)
View GitHub Profile
let test1; // undefined
let test2 = null; // null
const check = val => val ? 'ok' : 'ng';
check(false); // 'ng'
check(0); // 'ng'
check(""); // 'ng'
check(NaN); // 'ng'
check(null); // 'ng'
import numpy as np
single_perceptron = lambda x, w, theta: 0 if np.sum(w * x) + theta <= 0 else 1
and_perceptron = lambda x: single_perceptron(x, np.array([0.5, 0.5]), -0.7)
nand_perceptron = lambda x: single_perceptron(x, np.array([-0.5, -0.5]), 0.7)
or_perceptron = lambda x: single_perceptron(x, np.array([0.5, 0.5]), -0.2)
xor_perceptron = lambda x: and_perceptron(np.array([nand_perceptron(x), or_perceptron(x)]))
INPUT_DATA = np.array([[0, 0], [1, 0], [0, 1], [1, 1]])
@sin-to-jin
sin-to-jin / standard_deviation.py
Last active October 14, 2016 07:50
Standard deviation variant
import numpy as np
class Rule(object):
"""Standard Deviation Rules 68%, 95% Variant"""
STANDARD_DEVIATION_RANGE = 2
MAX_VALUE = 100
MIN_VALUE = 0
cleanMax = (lambda self, x: self.MAX_VALUE if x >= self.MAX_VALUE else x)
@sin-to-jin
sin-to-jin / fibonacci.py
Last active October 14, 2016 19:21
Python function
class Fibonacci(object):
"""Fibonacci function."""
def __init__(self):
print 'Fibonacci'
def fibonacci(self, n):
if n == 0:
return 0
elif n == 1:
# ##################################### #
# AmazonLinux minimal install For bash. #
# ##################################### #
# yum
sudo yum install -y sqlite-devel postgresql-devel postgresql-server git gcc gcc-c++ openssl-devel readline-devel glibc-headers readline libyaml-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel nginx
# anyenv
git clone https://github.com/riywo/anyenv ~/.anyenv
'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.bashrc
@sin-to-jin
sin-to-jin / bound
Last active December 27, 2015 16:09
task myType << { task action }