Skip to content

Instantly share code, notes, and snippets.

View RyotaBannai's full-sized avatar
🛴
Man's soil is still rich enough to direct his own life.

Ryota Bannai RyotaBannai

🛴
Man's soil is still rich enough to direct his own life.
View GitHub Profile
import numpy.linalg as la
def tls(X,y):
if X.ndim is 1:
n = 1 # the number of variable of X
X = X.reshape(len(X),1)
else:
n = np.array(X).shape[1]
Z = np.vstack((X.T,y)).T
@RyotaBannai
RyotaBannai / leopold_fc660c_programming.md
Created May 21, 2022 11:40 — forked from markuscraig/leopold_fc660c_programming.md
Leopold FC660C TMK Keymap Programming

Leopold FC660C TMK Keymap Programming

  1. Build a keymap and download the TMK firmware (.hex file)
  2. Install flash programming tools...
    • Mac
      • $ brew tap osx-cross/avr
      • $ brew install avr-gcc
      • $ brew install dfu-programmer
    • Linux / Windows
  • Use the 'Atmel FLIP' app
@RyotaBannai
RyotaBannai / rustmemo.md
Created April 25, 2022 16:19 — forked from meganehouser/rustmemo.md
Rustの個人的なメモ

Rustメモ

リテラル

  • 数字
let n1: f32 = 1.0f32;
let n2: isize = 0xF1A; // 16進数
let n3: isize = 0b11001; // 2進数
@RyotaBannai
RyotaBannai / string_format.rs
Created February 7, 2021 09:43 — forked from YusukeHosonuma/string_format.rs
Rust: Format string. (println!)
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
@RyotaBannai
RyotaBannai / string-conversion.rs
Created February 2, 2021 15:35 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@RyotaBannai
RyotaBannai / isexist_vs_isnotexist.go
Created December 29, 2020 13:11 — forked from mastef/isexist_vs_isnotexist.go
os.IsExist(err) vs os.IsNotExist(err)
/*
Watch out, os.IsExist(err) != !os.IsNotExist(err)
They are error checkers, so use them only when err != nil, and you want to handle
specific errors in a different way!
Their main purpose is to wrap around OS error messages for you, so you don't have to test
for Windows/Unix/Mobile/other OS error messages for "file exists/directory exists" and
"file does not exist/directory does not exist"
@RyotaBannai
RyotaBannai / usePrompt.tsx
Created August 2, 2020 13:26 — forked from sibelius/usePrompt.tsx
Prompt user before leaving route or reload
import { useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
export const usePrompt = (when: boolean, message: string = 'Are you sure you want to quit without saving your changes?') => {
const history = useHistory();
const self = useRef(null);
const onWindowOrTabClose = event => {
if (!when) {
@RyotaBannai
RyotaBannai / README.md
Created June 21, 2020 05:13 — forked from Tynael/README.md
How to use npx to run gist based scripts
@RyotaBannai
RyotaBannai / type-bounds.scala
Created April 15, 2020 10:47 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@RyotaBannai
RyotaBannai / git-reflog.md
Created January 22, 2020 12:10 — forked from kymmt90/git-reflog.md
`git reflog` についてまとめてみる

git reflog についてまとめてみる

reflog とは

  • reflog(参照ログ)とは HEAD やブランチ先端の動きの履歴
    • 各個人のローカルリポジトリに存在
    • ブランチの切り替え、新たに加えられた変更のプル、履歴の書き換え、あるいは単なる新規コミットの実行などを記録
  • git reflog で HEAD の移動履歴を、git reflog <ブランチ名> でそのブランチ先端が指していたコミットの一覧を確認可能
    • HEAD@{5}: HEAD の五つ前の状態を示す