Skip to content

Instantly share code, notes, and snippets.

jqを使ってJSONを処理する

jq というWritten in C な、ようやるわなJSONプロセッサがあってですね。

フィルタやちょっとした算術演算もできて、端末でAPI使った開発するのが大変捗る。
curl + jq で結構何とかなる。

インストール

簡単なので略。
ビルドも不要、つーか、ダウンロードした時点で圧縮もされてない実行可能バイナリが手に入る。
v1.3で600KBくらい。

@yu81
yu81 / printout.js
Last active December 23, 2015 11:59 — forked from tricknotes/printout.js
// For printout https://gist.github.com
// DOM
$('#header').remove();
$('#repos').remove();
$('.secondary').remove();
$('.meta').remove();
$('#footer').remove();
$('.push').remove();
$('#comments').remove();
@yu81
yu81 / check_bash_version_ec2.sh
Last active August 29, 2015 14:06
Check version of bash each AWS EC2 instances written in /etc/hosts.
# Check version of bash each AWS EC2 instances written in /etc/hosts.
# As for tomahawk options, see http://tomahawk.readthedocs.org/en/latest/tomahawk.html
# logged in as a user which has the same password in each server.
echo YOUR_COMMON_PASSWORD |
# execute tomahawk.
# yarr is one of a utility command in OpenUsp-Tukubai (https://github.com/usp-engineers-community/Open-usp-Tukubai)
tomahawk --login-password-stdin -c -h -t 10 \
"$(awk '$0~/^(10|192|172)\./{print $1}' /etc/hosts|yarr|tr " " ",")" \
'echo ${HOSTNAME} $(LANG=C yum info bash|grep amzn1|head -1)'
@yu81
yu81 / get_wild_hyuza_location.sh
Last active August 29, 2015 14:08
Find Wild Hyuza at Astoltia by scraping Yahoo! Realtime Search using cooccurrence word of Hyuza(ヒューザ).
curl 'http://realtime.search.yahoo.co.jp/search?p=%E3%83%92%E3%83%A5%E3%83%BC%E3%82%B6&ei=UTF-8' |
sed -e 's/\\n//g' |
egrep -o '<em>ヒューザ<\/em> .+<\/a><\/dd>' |
sed -e 's/[a-zA-Z\/<>]//g' |
awk '{print ($2 != "") ? $2 : "Hyuza not found.";}'
@yu81
yu81 / file0.sh
Last active August 29, 2015 14:18
シェルスクリプトでの == を認めているのはbashだけ? ref: http://qiita.com/YU81/items/b1bde03c06b45f7d267f
$ [ a = b ] && echo true || echo false
false
$ [ a == a ] && echo true || echo false
true
#!/bin/bash
# Initialize Amazon Linux AMI 2015.03 for PHP7 Web Application
# yum
# update default
sudo yum upgrade --enablerepo="*" -y
# install php7
[ ! -s remi-release-6.rpm ] && curl http://remi.kazukioishi.net/enterprise/remi-release-6.rpm > remi-release-6.rpm
sudo yum localinstall -y remi-release-6.rpm
sudo yum install scl-utils --enablerepo="*" -y
#!/bin/bash -xv
# Initialize Amazon Linux AMI 2015.03 for PHP5 Web Application
# yum
# update default
sudo yum upgrade --enablerepo="*" -y
# install php
for i in $(seq 3)
do
[ ! -s remi-release-6.rpm ] && curl --connect-timeout 3 http://remi.kazukioishi.net/enterprise/remi-release-6.rpm > remi-release-6.rpm
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user www;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
#!/bin/bash -xv
# Initialize Amazon Linux AMI 2015.09 for PHP7 Web Application
# yum
# update default
sudo yum upgrade --enablerepo="*" -y
# install php
for i in $(seq 3)
do
[ ! -s remi-release-6.rpm ] && curl --connect-timeout 3 http://remi.kazukioishi.net/enterprise/remi-release-6.rpm > remi-release-6.rpm