Skip to content

Instantly share code, notes, and snippets.

@ishiy1993
ishiy1993 / diffusion.fmr
Created October 5, 2017 16:26
Formura bug sample
dimension :: 1
axes :: x
double :: h = 1/NX
double :: cfl = 0.1
double :: dt = cfl*h*h
dd = fun(q) (q[i+1] + q[i-1] - 2*q[i])/(h**2)
begin function q = init()

Keybase proof

I hereby claim:

  • I am ishiy1993 on github.
  • I am ishiy (https://keybase.io/ishiy) on keybase.
  • I have a public key ASAOAzd0s4v7Qh4D-5L6PiRb8zjSFNXNqktSR9lpDaJuxAo

To claim this, I am signing this object:

@ishiy1993
ishiy1993 / getSysInfo.py
Created August 3, 2017 15:44
Display CPU and Memory usage
#!/usr/bin/python
import sys
import time
def read_cpu_info():
with open("/proc/stat", 'r') as f:
cpu = next(f).split(' ')
cpu_busy = sum([int(b) for b in cpu[2:5]])
cpu_total = cpu_busy + int(cpu[5])
return (cpu_total, cpu_busy)
#!/bin/bash
unzip hanshin.xlsx
cat xl/sharedStrings.xml | hxselect si -s '\n' | sed 's;</t.*;;' | sed 's;.*>;;' | awk '{print "s;s"(NR-1)";"$1";g"}' | tac > table
cat xl/worksheets/sheet1.xml | hxselect row -s '\n' | sed 's/<[^<]*>/ /g' | awk 'NR>1{print $1,"s"$2,"s"$3}' > temp
sed -f table temp
main = do
ds <- lines <$> getContents
print $ map solve ds
solve :: String -> (String,String)
solve str = (key, value)
where
key = takeWhile (/=':') str
value = tail $ dropWhile (/=':') str
@ishiy1993
ishiy1993 / fish_prompt.fish
Created November 13, 2016 00:14
fishのプロンプト
set __fish_git_prompt_showdirtystate 'yes'
set __fish_git_prompt_showstashstate 'yes'
set __fish_git_prompt_showupstream 'yes'
set __fish_git_prompt_color_branch yellow
function fish_prompt --description 'Write out the prompt'
printf '%s%s%s@%s%s%s%s\n> ' (set_color --bold magenta) (whoami) (set_color normal) (set_color blue) (echo $PWD) (set_color normal) (__fish_git_prompt)
end
@ishiy1993
ishiy1993 / N_Queen.hs
Created July 15, 2016 13:08
HaskellでNクイーン問題
import Data.List
import System.Environment
main :: IO ()
main = do
[n] <- getArgs
let ans = solves (read n)
mapM_ print ans
print $ length ans
@ishiy1993
ishiy1993 / Dockerfile
Created July 10, 2016 13:51
Elm 0.17の開発環境
FROM node:6.3
RUN npm install -g elm
RUN useradd --user-group --create-home --shell /bin/false app
ENV HOME=/home/app
USER app
WORKDIR $HOME
CMD ["bash"]
@ishiy1993
ishiy1993 / bash_ex1.sh
Created February 27, 2016 02:25
bashの変数展開の活用。変数が空の場合の処理。
#!/bin/bash
arg1=${1:?Need arguments}
arg2=${2:-!!!}
echo Hello ${arg1}${arg2}
@ishiy1993
ishiy1993 / ground.hs
Last active November 27, 2015 22:21
HaskellでOpenGL(GLUT)を使って、地面を描画する。
import Graphics.UI.GLUT
import Data.IORef
display :: IORef GLdouble -> IORef GLdouble -> DisplayCallback
display rot1 rot2 = do
clear [ColorBuffer, DepthBuffer]
r1 <- get rot1
r2 <- get rot2
loadIdentity
rotate r1 $ Vector3 1 0 0