Skip to content

Instantly share code, notes, and snippets.

@piruty
piruty / convert_roman_num.py
Created Aug 8, 2021
入力された数値をローマ字記法に変換して返却する
View convert_roman_num.py
# -*- coding: utf-8 -*-
M = 1000
C = 100
X = 10
I = 1
def num_to_roman(number=2015):
num_M = number / M
number = number % M
@piruty
piruty / write_csv.rb
Created Aug 8, 2021
CSV書き込みサンプル in ruby
View write_csv.rb
require 'csv'
data = [1,2,3,4,5]
CSV.open("data.csv", "w") do |csv|
csv << data
end
@piruty
piruty / extract_mfcc_from_wav.jl
Created Jan 13, 2021
Juliaを使ってwavファイルからMFCCを抽出する
View extract_mfcc_from_wav.jl
# using Pkg; Pkg.add('WAV'); Pkg.add('MFCC')
using WAV
using MFCC
y, _ = wavread("path/to/wavfile")
mfcc(y)
@piruty
piruty / make_scrapbox_link_for_ios.js
Created Feb 14, 2020
開いているページのScrapbox表記のリンクを作るためのブックマークレット iOS版
View make_scrapbox_link_for_ios.js
@piruty
piruty / make_scrapbox_link.js
Created Feb 14, 2020
開いているページのScrapbox表記のリンクを作るためのブックマークレット
View make_scrapbox_link.js
@piruty
piruty / Dockerfile
Last active Feb 11, 2020
「ふつうのコンパイラをつくろう」のcbcを実行するためのDockerfile
View Dockerfile
FROM i386/centos:7
WORKDIR /work
RUN yum update -y && yum install -y wget gcc java-1.8.0-openjdk && yum clean all
RUN wget http://www.loveruby.net/archive/cbc/cbc-1.0.tar.gz
RUN tar xzf cbc-1.0.tar.gz
RUN cd cbc-1.0; ./install.sh
@piruty
piruty / converter.rb
Created Feb 2, 2020
md2sbした後のテキストを一括で取り込むためのJSONに変換するスクリプト
View converter.rb
require 'json'
filenames = Dir.glob('docs/*')
result = {pages: []}
filenames.each do |filename|
File.open(filename, 'r') do |file|
title = filename.gsub(/docs\//, '').gsub(/\.md/, '')
lines = []
file.each_line do |line|
@piruty
piruty / tab_color.fish
Created Feb 2, 2020
Function to change item tab color with fish shell (inspired by [Change iTerm2 tab color when using SSH](https://gist.github.com/wadey/1140259) )
View tab_color.fish
function tab_color --description "set iterm tab color"
set red $argv[1]
set green $argv[2]
set blue $argv[3]
echo -ne "\033]6;1;bg;red;brightness;$red\a"
echo -ne "\033]6;1;bg;green;brightness;$green\a"
echo -ne "\033]6;1;bg;blue;brightness;$blue\a"
end
View sqlite3.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.