Skip to content

Instantly share code, notes, and snippets.

View taznica's full-sized avatar

Taichi Tsuchida taznica

View GitHub Profile
private float ScaleValue(float value, float[] from, float[] to)
{
var scale = (to[1] - to[0]) / (from[1] - from[0]);
var capped = Math.Min(from[1], Math.Max(from[0], value)) - from[0];
return capped * scale + to[0];
}
class Singleton {
static final Singleton _singleton = Singleton._();
factory Singleton() {
return _singleton;
}
Singleton._();
}
#!/usr/bin/env bash
echo "echo.sh"
./echo_2.sh
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tensorflow as tf
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
def load_data():
@taznica
taznica / Sort videos by popularity
Created December 23, 2021 12:39
Chrome bookmarklet
javascript:(function(){window.location.href = window.location.href + '?sort=p';})();
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def f(s: str, n: int):
if n > 0:
return s[:len(s) // 2] * n + s[len(s) // 2:] * n
# return s[:len(s) // 2] + f(s, n - 1) + s[len(s) // 2:]
else:
return ''
@charset "UTF-8";
/*!
* Marp irodori theme.
*
* @theme irodori
* @author taznica
*
* @auto-scaling true
* @size 16:9 1280px 720px
*/
/*! @theme orange */
/* $color-white: #FFFFF0; */
/* $color-black: #323232; */
/* $color-green: #42B983; */
@import 'default';
section {
background-color: #FFFFF0;
@taznica
taznica / bark.js
Created May 22, 2020 09:45
console.dog()
console.dog = (bark, l = bark.toString().length / 1.66) => {
console.log(`
/ ̄${` ̄ ̄`.repeat(l)} ̄
🐶 < `,bark,`
\\_${`__`.repeat(l)}_
`)
}
console.dog('wan wan')
console.dog({ja: 'wan wan', en: 'bow wow'})
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Singleton:
_instance = None
def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super(Singleton, cls).__new__(cls)