Skip to content

Instantly share code, notes, and snippets.

@hashimotor
hashimotor / amazon_extract.js
Created August 15, 2013 05:54
Amazonの本の単価や出版社を表示する。正確にパースしてないのでよく失敗する
javascript:(function(){%20function%20g(e){return%20document.getElementById(e);};%20var%20s="%E6%9B%B8%E5%90%8D\n"%20+%20g("btAsinTitle").firstChild.data%20+"\n%E8%91%97%E8%80%85\n"%20+g("btAsinTitle").parentNode.nextSibling.nextSibling.firstChild.data%20+"\n%E7%99%BA%E8%A1%8C%E8%80%85\n"%20+g("SalesRank").parentNode.childNodes[3].childNodes[1].data.trim().split("%20")[0]%20+"\nISBN\n"%20+g("SalesRank").parentNode.childNodes[5].childNodes[1].data.trim()%20+"\n%E5%8D%98%E4%BE%A1\n"%20+g("actualPriceValue").childNodes[0].childNodes[0].data.trim().replace(/.*(\d),(\d\d\d).*/,"$1$2")%20+"\n%E7%99%BA%E8%A1%8C%E5%B9%B4\n"%20+g("SalesRank").parentNode.childNodes[3].childNodes[1].data.match(/\d+/)[0];%20alert(s);%20})();
robocopy "%home%" "\\nas" /S /R:0
@hashimotor
hashimotor / fabfile.py
Created July 14, 2013 07:23
serverspecのexampleをenvassertで書くと
from fabric.api import task
from envassert import file, process, package, port
@task
def apache2():
assert package.installed("apache2")
assert service.is_enabled("apache2")
assert service.is_up("apache2")
@hashimotor
hashimotor / ssh_pipe_scp.sh
Last active December 19, 2015 09:19
Remote copy using ssh and pipe. http://d.hatena.ne.jp/pcmaster/20130630/p1
ssh src_host 'cat file' | ssh dst_host 'cat > file'
@hashimotor
hashimotor / check_nic.sh
Last active December 17, 2015 10:58
Nagios NIC link monitor plugin
#!/bin/bash
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3
while test -n "$1"; do
case "$1" in
--interface|-i)
@hashimotor
hashimotor / apache2.conf
Created May 12, 2013 00:30
ホスト制限とユーザ認証を併用する
<Directory /var/www/>
AuthType Digest
AuthName <realm>
AuthDigestDomain <path>
AuthUserFile <htdigest>
Order deny,allow
Deny from all
Allow from <ipaddress>
@hashimotor
hashimotor / user-data-init.sh
Last active December 16, 2015 19:39
AWS User data
#!/bin/bash -e
exec > >(tee >(logger -t "user-data")) 2> >(tee >(logger -t "user-data: ERROR") >&2)
echo user-data: BEGIN
date '+%Y-%m-%d %H:%M:%S'
dd if=/dev/zero of=/swap bs=1M count=1024
mkswap /swap
swapon /swap
echo "/swap none swap defaults 0 0" | tee -a /etc/fstab
echo "Asia/Tokyo" > /etc/timezone
echo LC_ALL=\"en_US.UTF-8\" | tee -a /etc/default/locale
@hashimotor
hashimotor / gist:5330440
Created April 7, 2013 13:13
iOSソフトウェア使用許諾契約
日本語
重要:お客様がiPhone、iPadまたはiPod touch(以下「iOSデバイス」といいます)をご使用になることで、お客様は、以下のAppleの定める各条項に基づく拘束を受けることに同意されたことになります。
A. Apple iOSソフトウェア使用許諾契約
B. Appleからの通知について
Apple Inc.
iOSソフトウェア使用許諾契約
シングルユースライセンス
@hashimotor
hashimotor / gist:4571897
Created January 19, 2013 10:40
Report Inappropriate Apps
This app[1] retrieves all the name, address, phone number, e-mail address from all the phone which the app is installed. This app discloses those private, confidential or not intend to be publicly accessible information to all the users of the app.
The user of this apps can search persons' address and phone number easily by querying using name or e-mail address.
The developer of the app says[2][3] this app is now fetching all of address book in which this app is installed, and they are now adding to the developer's databases.
The app violates the Content Policy: Personal and Confidential Information. also the app may be used in order to do Illegal Activities and Hate Speech.
[1] https://play.google.com/store/apps/details?id=info.jigensha.whitepage
@hashimotor
hashimotor / gist:3845513
Created October 6, 2012 17:19
Check server spec.
# http://codezine.jp/article/detail/4830
# cat /proc/cpuinfo | grep "model name"
model name : Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz
model name : Intel(R) Core(TM)2 Duo CPU E6850 @ 3.00GHz
# cat /proc/meminfo | grep MemTotal
MemTotal: 2015528 kB
# cat /etc/redhat-release
CentOS release 5.3 (Final)
# uname -a
Linux host 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux