Skip to content

Instantly share code, notes, and snippets.

View teru01's full-sized avatar

Teruya Ono teru01

  • Ubie, Inc.
  • Tokyo, JP
View GitHub Profile
@teru01
teru01 / server.py
Last active January 15, 2018 08:32
from bottle import Bottle, run, post, request, redirect
import wiringpi as wp
app = Bottle()
state = 0
stdict = {0:"turn off", 1:"turn on"}
wp.wiringPiSetupGpio()
wp.pinMode(2, 1)
@app.route('/')
int fibonacci(int n, int *p){
if(n == 0) {
p[0] = 0;
return p[0];
}else if(n == 1){
p[1] = 1;
return p[1];
}else{
p[n] = fibonacci(n-1, p) + fibonacci(n-2, p);
return p[n];
const makeImage = (elFile, file) => {
const elImage = document.createElement('img');
elFile.appendChild(elImage);
const reader = new FileReader();
reader.addEventListener('load', (e) => {
elImage.src = e.target.result;
});
reader.readAsDataURL(file);
};
<?php
$url = "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$file = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
@teru01
teru01 / rust.md
Last active April 27, 2019 09:27
Rustメモ

これなら問題ない

fn refe(addr: &String) {
    // addr.push('!');
    println!("{}", addr);    
}

fn main() {
 let mut v = "aa".to_string();
git_branch(){
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(git_branch)\$ "
@teru01
teru01 / kubectx_install.sh
Created June 2, 2020 01:50
kubectx installation script for fish shell.
sudo git clone https://github.com/ahmetb/kubectx /opt/kubectx
sudo ln -s /opt/kubectx/kubectx /usr/local/bin/kubectx
sudo ln -s /opt/kubectx/kubens /usr/local/bin/kubens
mkdir -p ~/.config/fish/completions
ln -s /opt/kubectx/completion/kubectx.fish ~/.config/fish/completions/
ln -s /opt/kubectx/completion/kubens.fish ~/.config/fish/completions/
@teru01
teru01 / setup.sh
Last active September 10, 2020 04:10
setup script
#!/bin/bash
set -ux
cd "${0%/*}"
dir=$(date +%Y-%m-%d-%H-%M-%S)
mkdir $dir
touch $dir/$dir
cp -a nginx.conf $dir
#!/bin/bash
set -ux
cd "${0%/*}"
dir="${1%/}"
cp kataribe.toml $dir
cat $dir/access.log | kataribe > $dir/result.txt
sudo cp -a /var/log/mysql/mysql-error.log $dir
#!/bin/bash
cd "${0%/*}"
curl -s http://localhost:<port>/debug/pprof/profile?seconds=60 > $1/cpu.pprof
go tool pprof -png $1/cpu.pprof > $1/cpu.png