Skip to content

Instantly share code, notes, and snippets.

View jiro4989's full-sized avatar
🏠
Working from home

jiro jiro4989

🏠
Working from home
View GitHub Profile
@jiro4989
jiro4989 / note.ps1
Created December 26, 2017 13:32
PowerShellメモ
# 標準出力の文字コードをUTF-8に変更
$OutputEncoding = [System.Console]::OutputEncoding
# 上を実行してから下のようにUTF8のファイルをクリップボードにコピーすると文字化けしない
cat .\pickup_process.go -Encoding utf8 | clip
####################################################
# Nameプロパティがtmp.logのテキストファイルのみ出力
Get-ChildItem . -Recurse | % { if ($_.Name -eq "tmp.log") { echo $_ } }
@jiro4989
jiro4989 / out_pkgs.bat
Created December 31, 2017 02:02
Chocolateyのインストール済みパッケージ一覧をCLIのみでpackage.configに吐き出す手順 ref: https://qiita.com/jiro4989/items/fffc433d2eddcfa8edd5
@echo off
powershell Set-ExecutionPolicy RemoteSigned
powershell .\out_pkgs.ps1
powershell Set-ExecutionPolicy Restricted
@jiro4989
jiro4989 / OrgCellClass.kt
Last active July 6, 2021 16:01
KotlinでJavaFXのListViewに独自データクラスを追加して、表示されるテキストを変更する方法
// この例ではFileのデータを持つ
listView.cellFactory = Callback<ListView<File>, ListCell<File>> {
object : ListCell<File>() {
override fun updateItem(item: File?, empty: Boolean) {
super.updateItem(item, empty)
if (item != null) text = item.name
}
}
}
@jiro4989
jiro4989 / ConfigDao.kt
Last active February 12, 2018 09:49
KotlinでXML操作
package jiro.app.dao
import org.w3c.dom.Element
import java.io.File
import javax.xml.parsers.DocumentBuilderFactory
data class ConfigModel(val versions: List<VersionModel>)
data class VersionModel(val id: String, val image: ImageModel)
data class ImageModel(val columnCount: Int, val rowCount: Int, val oneTile: OneTileModel)
data class OneTileModel(val width: Int, val height: Int)
@jiro4989
jiro4989 / frequency_distribution.awk
Created March 11, 2018 11:21
awkで度数分布
#!/bin/awk
# vim:tw=0
# 外部から入力する変数(定数)
# const:MAX ループ回数。集計範囲の上限を決定する
# const:BINSIZE 区間
# 集計の範囲 (BINSIZE=10000の場合)
# 0 < i <= 10000
# 10000 < i <= 20000
@jiro4989
jiro4989 / agg-log.clj
Last active March 25, 2018 11:57
アクセスログの末尾の秒数を集計する
(ns clojuretest.core
(:require [clojure.string :as str]))
(defn -main
"description"
[& args]
(let [nums (->> (-> "HOME"
System/getenv
(str "/Documents/access_log")
slurp
@jiro4989
jiro4989 / agg.log
Last active March 25, 2018 12:41
自作のイラストのタイムスタンプを月単位、年単位で集計する
date count date count
------- --- ------- ---
2011-11 6 2011 8
2011-12 2 2012 46
2012-01 2 2013 13
2012-02 2 2015 11
2012-03 20 2016 88
2012-04 8 2017 4
2012-05 4 ------- ---
2012-06 3 total 170
@jiro4989
jiro4989 / agg_ext.sh
Last active April 8, 2018 07:13
指定のディレクトリ配下のソースコードを日付と拡張子ごとに集計するワンライナー
#!/bin/bash
# 使い方
# bash agg_ext.sh .
set -eu
target_dir=$1
find $target_dir -type f -printf "%TY-%Tm %p\n" |
@jiro4989
jiro4989 / convemen.sh
Last active April 8, 2018 07:14
ファイル名の全角を半角に変換してmv
#!/bin/bash
set -eu
target_dir=$1
find $target_dir -type f |
while read -r f
do
nf=`echo $f | nkf -Z | sed -r 's@ - @_@g' | sed -rE 's@ | @_@g'`
@jiro4989
jiro4989 / chart.go
Created April 29, 2018 02:19
Go言語でレーダーチャートを書く(途中)
package main
import (
"fmt"
"image"
"image/color"
"image/png"
"log"
"math"
"os"