Skip to content

Instantly share code, notes, and snippets.

View falgon's full-sized avatar
💭
I may be slow to respond.

Roki falgon

💭
I may be slow to respond.
View GitHub Profile
@falgon
falgon / bayes_venn.py
Last active July 26, 2018 06:19
Visualization of the probability of events
import matplotlib
matplotlib.use('AGG')
from collections import Counter
from matplotlib import pyplot as plt
from matplotlib import patches as mpatches
from matplotlib.lines import Line2D
from matplotlib_venn import venn2
@falgon
falgon / montyhall.py
Created July 27, 2018 07:56
Visualization of monty hall problem
from random import randrange
from matplotlib import use
use('AGG')
from matplotlib import pyplot as plt
class MontyHallproblem:
def __init__(self, fname, tryN):
self.fname = fname
@falgon
falgon / simple_norm.py
Created September 25, 2018 05:32
blog fig
import scipy.stats.distributions as dis
import numpy as np
import pylab as pl
from matplotlib import pyplot as plt
def main():
plt.rc('text', aa=True, usetex=True)
x = np.arange(-5, 5, 0.1)
for i in range(1, 6):
@falgon
falgon / cube_and_section.py
Last active September 29, 2018 03:05
The figure of cube and its section
from matplotlib import use
use('AGG')
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from mpl_toolkits.mplot3d import Axes3D
from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection
class cube_fig:
def __init__(self, fname, rectangle):
@falgon
falgon / LinearEquationsPlot2.hs
Last active October 24, 2018 16:36
Linear equations method.
module Main where
import Control.Monad.Fix (fix)
import Data.Bool (bool)
import Data.Tuple.Extra (first, second, dupe, (***))
import Data.Maybe (maybe)
import Graphics.Rendering.Chart.Backend.Cairo
import Graphics.Rendering.Chart.Easy
import System.IO (IOMode (..), withFile, hGetLine, hIsEOF)
import System.Exit (exitFailure)
@falgon
falgon / live_preview.py
Last active July 5, 2019 16:39
My blog live reviewer
#!/usr/bin/env python3
from livereload import Server, shell
from sys import argv
class live_view:
def __init__(self):
self.sv = Server()
self.is_run = False
def __enter__(self):
@falgon
falgon / asm_dsl_eg_impl.cpp
Last active January 17, 2020 15:20
Example implementation of monadic assembly language DSL using C++17 and etc (One of my graduation studies)
#include <boost/preprocessor/seq/for_each.hpp>
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <functional>
#include <iostream>
#include <iterator>
#include <sstream>
#include <tuple>
#include <type_traits>
namespace dhu_grad {
@falgon
falgon / addtag.sh
Last active November 15, 2021 04:58
TagSpaces (https://www.tagspaces.org/) を使うに当たって CLI 上でタグを付与 (ファイル名を変更) するユーティリティツール
#!/bin/bash
set -euf
# set exported tagspaces json file path
# e.g. json_name="$HOME/.config/tag-lib.json" addtag -show
declare json_name
help_message() {
echo "Usage:"
@falgon
falgon / porting.sh
Created August 9, 2020 10:05
Simple script to migrate from my old blog to new blog
#!/bin/bash
function fix_metadata() {
i="$1"
fname="$2"
line="$3"
if [ "`echo "$line" | grep 'Title'`" ]; then
sed -i -e "${i}s/Title/title/g" "$fname"
elif [ "`echo "$line" | grep 'Tags'`" ]; then
@falgon
falgon / radiko_2020.sh
Created November 28, 2020 08:20 — forked from FREEWING-JP/radiko_2020.sh
radikoをlinuxで聞いたり録音したりするやつ 2020年対応版
#!/bin/bash
# https://mtunn.wordpress.com/odroid-u2★セットアップ/radikoの録音・再生(archlinux)/
pid=$$
wkdir='/var/tmp'
playerurl=https://radiko.jp/apps/js/flash/myplayer-release.swf
playerfile="${wkdir}/player.swf"
keyfile="${wkdir}/authkey.png"
auth1_fms="${wkdir}/auth1_fms_${pid}"
auth2_fms="${wkdir}/auth2_fms_${pid}"