Skip to content

Instantly share code, notes, and snippets.

View rluisr's full-sized avatar
🤒
Out sick

Hasegawa Takuya rluisr

🤒
Out sick
View GitHub Profile
@rluisr
rluisr / hook.php
Created December 17, 2015 10:37
GitHub Webhook. Deploy to Twitter.
<?php
require_once 'tweet/tweet.php';
$secret = "3LxNHeLXEzJS";
//全てのリクエストヘッダーを取得
$headers = getallheaders();
//署名されたのを取得
$hubSignature = $headers['X-Hub-Signature'];
@rluisr
rluisr / SquidInfo.php
Last active February 4, 2016 05:56
Zabbixでsquidclient
<?php
/**
* Squid の File descriptor を引数で取得するもの
* Zabbix で 使ってください。
*/
/**
* @param string $host 第1引数 IPアドレス
* @param string $key 第2引数 maximum or largest or number or file or .....
*/
@rluisr
rluisr / smart.php
Created May 30, 2016 07:56
S.M.A.R.T check for Zabbix
<?php
/**
SMARTで異常があるかどうか調べる。
( This script checks S.M.A.R.T for Zabbix. )
=== Setting ===
[zabbix_agentd.conf]
+ UserParameter=hdd.smart[*],/usr/bin/php /path/to/smart.php $1 $2 $3
+ AllowRoot=1
@rluisr
rluisr / rc
Last active June 29, 2016 02:50
Notify you through Slack when SSH connection is established.
#!/bin/bash
url="<web hook url>"
readonly USER=`whoami`
readonly HOST=`hostname`
ip=`lastlog | grep -w "${USER}" | awk '{print $3}'`
day=`lastlog | grep -w "${USER}" | awk '{print $4}'`
month=`lastlog | grep -w "${USER}" | awk '{print $5}'`
@rluisr
rluisr / app.js
Created July 29, 2016 16:57
【Node.js】 Check tracking status. This code supports 349 couriers. Notify with Twitter.
/*
* Notify tracking status with Twitter on Node.js.
*
* Usage
* -------------------
* node app.js "<tracking number>" "<your twitter username>"
*
* This code scraping 'track.aftership.com'
*/
@rluisr
rluisr / shutdown.sh
Last active October 7, 2016 05:07
Shutdown All VMs. Using `virsh`.
#!/bin/bash -e
virsh list --all | egrep '実行中|running' | awk '{print $2}' | xargs -t -I {} virsh shutdown {}
@rluisr
rluisr / check_cache.php
Created January 15, 2017 08:21
check wordpress WP_CACHE
<?php
function check_cache()
{
$path = preg_replace("/wp-content/", " ", WP_CONTENT_DIR);
$path = trim($path);
$wp_config = file_get_contents("${path}wp-config.php");
if (preg_match("/^define\('WP_CACHE',\s*true\);/mi", $wp_config) === 1) {
file_put_contents(WP_CONTENT_DIR . '/block-wpscan/cache_status', "1", LOCK_EX);
@rluisr
rluisr / startup-api.service
Created January 25, 2017 13:47
Add service as systemd
[Unit]
Description=Run API program as node user on boot
[Service]
Type=simple
RemainAfterExit=yes
User=node
ExecStart=/usr/bin/forever start /home/node/Web-API/app.js
ExecStop=/usr/bin/forever stop /home/node/Web-API/app.js
ExecReload=/usr/bin/forever restart /home/node/Web-API/app.js
@rluisr
rluisr / stop.sh
Created February 11, 2017 10:10
for
#!/bin/bash
i=$1
shift
(sleep $i; kill $$) & exec "$@"
@rluisr
rluisr / reboot-all-lxc.sh
Created May 2, 2017 16:34
[Bash one liner] Reboot all LXC Container
for i in `(lxc-ls)`; do lxc-stop -n $i -r; done