Skip to content

Instantly share code, notes, and snippets.

View digitalm's full-sized avatar

mika mizuno digitalm

View GitHub Profile
@digitalm
digitalm / MicrosoftOfficeLicence-Last5char
Last active August 29, 2015 14:19
Officeのライセンスキーの末尾5文字を取得する
# このコードをcmd.exeで実行する
cscript "%programfiles%\Microsoft Office\Office14\ospp.vbs" /dstatus
# 出力される YYYYY に書いてある
# Microsoft (R) Windows Script Host Version 5.8
# Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
#
# ---Processing--------------------------
# ---------------------------------------
# SKU ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
@digitalm
digitalm / OpenSSL Key-Cert Confirmation
Last active August 29, 2015 14:19
OpenSSLで秘密鍵と証明書の確認
# SSL更新で証明書と鍵のペアの正当性を確認
#
# 証明書
openssl x509 -noout -modulus -in /path/to/crt.crt | openssl md5
# => XXXXYYYYZZZZ(32桁の文字列など)
#
# 鍵
openssl rsa -noout -modulus -in /path/to/key.key | openssl md5
# => XXXXYYYYZZZZ(32桁の文字列など)
@digitalm
digitalm / Find Recent updated files
Last active August 29, 2015 14:19
最近更新されたファイル順に並べるshell
find . -type f -mmin -86400
# 1日以内なら 24*60*60 で 86400を指定
@digitalm
digitalm / configure-git-completion.md
Last active October 26, 2017 06:59
bash/zsh git-completion support

概要

  1. 補完用シェルスクリプトを任意の場所に置く
/Users/mika/.git-completion.sh
  1. 起動時に読み込む

手順

  1. スクリプトをコピーしてくる
@digitalm
digitalm / file0.txt
Last active April 6, 2018 01:47
ActiveRecord::Migration で string のカラムをデータごと integer に変換する ref: https://qiita.com/digitalm/items/919908bdb152c3a068e9
def up
change_column :reports, :file_size, 'integer USING CAST(file_size AS integer)'
end
def down
change_column :reports, :file_size, :string
end
@digitalm
digitalm / retreave gs.txt
Last active September 23, 2020 17:41
Installing Ghostscript 9.23 ( to Amazon linux )
## to install
cd /usr/local/src/
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs923/ghostscript-9.23.tar.gz
tar -zxvf ghostscript-9.23.tar.gz
cd ghostscript-9.23
./configure --disable-compile-inits --with-x --with-drivers=ALL --without-luratech --with-libiconv=gnu --prefix=/usr/local
make
make install
@digitalm
digitalm / gs sample.txt
Created July 20, 2018 03:39
ghostscript command sample
# get whole page size from sample.pdf
# 総ページ数を取得
$ gs -q -dNODISPLAY -c '(sample.pdf) (r) file runpdfbegin pdfpagecount = quit'
# take perticular page from sample.pdf with sequential file name like printed_0001.pdf, printed_0002.pdf
# 特定範囲のページを取り出す
# 総ページ数でループすれば、分割にも応用可
$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dFirstPage=1 -dLastPage=1 -sOutputFile=printed_%04d.pdf sample.pdf

TL;DR

開発環境は以下のような準備をしていただけるとスムーズかも。
docker未導入なので、モダンでなく、たいへん申し訳ございません 🙇
環境の作成でなにか詰まったり困ったら、当gistにコメントいただるといいかもしれません (が、勤務時間外だと返信が遅くなるかもしれません)

version install example
ruby ruby 2.3.7p456 (2018-03-28 revision 63024) [x86_64-darwin17] rbenv install -v 2.3.7 && rbenv rehash
postgres 9.5.13 brew install postgresql@9.5 && brew switch postgresql@9.5 9.5.13 && postgres -D /usr/local/var/postgresql@9.5
@digitalm
digitalm / sample.sh
Last active July 26, 2018 10:15
setval postgresql upto...
# companies テーブルの id を 2001 から始める
$ psql -d database_name
$ database_name=# SELECT setval(pg_get_serial_sequence('companies', 'id'), 2001);
setval
--------
2001
(1 row)
@digitalm
digitalm / gist:9a6e8e56a62a84975f843315e3501495
Last active August 18, 2018 14:24
setting up ( homebrew / git-completion )
# git-completion
$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.sh
$ chmod a+x ~/.git-completion.sh
# git-prompt
$ curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
$ chmod a+x ~/.git-prompt.sh
$ vi ~/.bash_profile
```