Skip to content

Instantly share code, notes, and snippets.

View tetlabo's full-sized avatar

鶴見教育工学研究所 tetlabo

View GitHub Profile
@tetlabo
tetlabo / worldcup2014_pgsql.sql
Created July 17, 2018 15:08
TECH Projin「SQL練習問題」PostgreSQL版
--- original file made by TECH Projin
--- http://tech.pjin.jp/blog/2016/12/05/sql%E7%B7%B4%E7%BF%92%E5%95%8F%E9%A1%8C-%E4%B8%80%E8%A6%A7%E3%81%BE%E3%81%A8%E3%82%81/
--- modified for PostgreSQL by Kenta Tanaka (https://mana.bi/)
SET timezone to "+00:00";
--
-- Database: "worldcup2014"
--
@tetlabo
tetlabo / simulation_Japanese_income.R
Created March 22, 2020 12:56
平成30年国民生活基礎調査に基づく、所得分布のシミュレーション
# 調査結果URL: https://www.mhlw.go.jp/toukei/saikin/hw/k-tyosa/k-tyosa18/index.html
# 統計表URL: https://www.e-stat.go.jp/stat-search/files?page=1&layout=datalist&toukei=00450061&kikan=00450&tstat=000001129675&cycle=7&tclass1=000001130605&stat_infid=000031835137&result_page=1
# 国民生活基礎調査より、年収分布の相対度数
vec.income.freq <- c(6.2, 13.7, 13.7, 13.6, 10.1, 8.5, 7.6, 5.9, 4.5, 4.2, 3.0, 1.8, 1.4, 1.6, 1.2, 0.5, 0.5, 0.4, 0.4, 0.1, 1.3)
# 相対度数をもとにした10000人のシミュレーション
vec.income.sim <- NULL
for (i in 1:10000) {
class <- sample(1:length(vec.income.freq), 1, prob = vec.income.freq)
if (class == 1){
# 100万円未満
@tetlabo
tetlabo / winget_list_20201111.txt
Created November 11, 2020 10:16
Windows Package Manager (winget) の収録パッケージ一覧: 2020-11-11版
名前 ID バージョン
---------------------------------------------------------------------------------------------
Robo3T 3T.Robo3T 1.4.1
Robo3T - Beta 3T.Robo3TBeta 1.4.2-beta
4K Slideshow Maker 4KDownload.4KSlideshowMaker 1.8.1
4K Stogram 4KDownload.4KStogram 3.1.1
4K Video Downloader 4KDownload.4KVideoDownloader 4.13.3
4K Video to MP3 4KDownload.4KVideoToMP3 3.0.0
ndm 720kb.ndm 1.2.0
Aya 7room.Aya 0.10.4
@tetlabo
tetlabo / local.conf
Last active November 14, 2020 09:50
「M+とIPAの合成フォント」、源ノ明朝、源ノ角ゴシック、源ノ角ゴシック Code JPをLinuxで使用するためのfontconfig設定ファイル
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<test name="family" compare="eq">
<string>IPAexMincho</string>
</test>
<edit name="hinting" mode="assign">
<bool>false</bool>
</edit>
@tetlabo
tetlabo / access_drive_on_colab_withR.R
Last active September 29, 2021 04:07
Google ColabでRを使いDriveにアクセスする
# 必要なパッケージのインストール
install.packages("tidyverse")
install.packages("googledrive")
install.packages("R.utils")
# パッケージの読み込み
library(tidyverse)
library(googledrive)
# 非対話モードでのGoogle Drive認証
@tetlabo
tetlabo / compare_object_size_between_character_and_factor.R
Created February 11, 2021 12:42
character型とfactor型のオブジェクトサイズの比較
vec <- sample(LETTERS, 10000, replace = TRUE)
print(object.size(vec))
vec <- as.factor(vec)
print(object.size(vec))
@tetlabo
tetlabo / fix_ja_font.R
Created March 2, 2021 16:39
RStudio Cloud / Shinyapps.ioで日本語フォントを使用できるようにする
download.file("https://raw.githubusercontent.com/ltl-manabi/R/master/fix_ja_font.sh", destfile = "fix_ja_font.sh")
system("bash ./fix_ja_font.sh")
@tetlabo
tetlabo / get_tokyo_temper.R
Created March 4, 2021 12:40
owmrパッケージを使ってOpenWeatherから現在の東京の気温を取得する
# owmrパッケージは、GitHub版でないと、APIキーの認証がうまくいきませんでした。
# https://github.com/crazycapivara/owmr
library(tidyverse)
library(owmr)
Sys.setenv(OWM_API_KEY = "APIキーを指定してください")
(tokyo_temper <- get_current("Tokyo", units = "metric") %>% owmr_as_tibble() %>% pull(temp))
@tetlabo
tetlabo / plot_sound.R
Created March 25, 2021 16:24
音声データ (MP3) をRでプロットする
library(tuneR)
library(ggplot2)
voice_orig <- readMP3(file.path("voice.mp3"))
# 音声の切り出し
start <- 0.6 * voice_orig@samp.rate
end <- 1.1 * voice_orig@samp.rate
voice <- voice_orig[start:end]
@tetlabo
tetlabo / plot_spectrogram.R
Created April 4, 2021 14:04
MP3データを読み込み、スペクトログラムを描画する
library(tuneR)
library(seewave)
mp3_files <- list.files(path = "mp3/", pattern = "*.mp3")
for (i in 1:length(mp3_files)) {
name <- gsub("mp3", "png", mp3_files[i])
voice <- readMP3(file.path(paste0("mp3/", mp3_files[i])))
# スペクトログラムの描画