Skip to content

Instantly share code, notes, and snippets.

@mithrandie
mithrandie / greedy.sql
Last active June 4, 2019 10:08
サイゼリヤ問題
/*
* サイゼリヤで1000円あれば最大何kcal取れるのか
*
* 【動作】
* 円あたりのカロリーが高い順に,1000円になるまでメニューを追加
*
* 【実行】
* こちらのデータを使用させてもらいます: https://github.com/hodaka0714/saize_calory_maxmization
* 実行環境: csvq version 1.11.4
* 実行手順:
@mithrandie
mithrandie / csvq_download_report.sql
Created March 5, 2019 00:24
Reports download count from csvq release page(https://github.com/mithrandie/csvq/releases)
/*
* Reports download count from csvq release page(https://github.com/mithrandie/csvq/releases).
*
* Usage:
* - Get information from GitHub API
* $ csvq -s csvq_download_report.sql
* - Load information from downloaded local file
* $ curl https://api.github.com/repos/mithrandie/csvq/releases -o ./releases/releases_20190302.json
* $ env GET_DATE=20190302 csvq -s csvq_download_report.sql
*/
@mithrandie
mithrandie / org-csvq.el
Last active October 15, 2018 07:57
Emacs functions on org-mode to use https://github.com/mithrandie/csvq
;; Replace current table with the result of the query.
(defun org-csvq-update ()
"run csvq update or delete query"
(interactive)
(unless (org-at-table-p) (user-error "No table at point"))
(org-table-align)
(let ((query (read-string "query: ")))
(let ((table (org-table-to-lisp (buffer-substring-no-properties (org-table-begin) (org-table-end))))
(query (format "%s SELECT * FROM stdin;" query))
(view))
@mithrandie
mithrandie / JPNUserDict_Header.txt
Last active July 17, 2018 10:56
Macの日本語辞書からPOBoxの辞書を作成
;This is the backup file of the user dictionary.
;A tab character is set before a word and after its reading.
;The supported encoding is UTF-8 and line break is CR+LF.
;Example1:
;そにー ソニー株式会社
;Example2:
;sony Sony Corporation
;
;You can use 50 characters per word and its reading.
;You can save up to 500 words in the user dictionary.
@mithrandie
mithrandie / wakeOnLAN.sh
Created June 4, 2018 08:26
wakeOnLAN on shell
echo -e $(echo $(printf 'f%.0s' {1..12}; printf "$(echo $MAC_ADDRESS | sed 's/://g')%.0s" {1..16}) | sed -e 's/../\\x&/g') | /usr/local/bin/ncat -u $BROADCAST_ADDRESS 9