Skip to content

Instantly share code, notes, and snippets.

Avatar
🤒
Out sick

Hasegawa Takuya rluisr

🤒
Out sick
View GitHub Profile
@rluisr
rluisr / hook.php
Created Dec 17, 2015
GitHub Webhook. Deploy to Twitter.
View hook.php
<?php
require_once 'tweet/tweet.php';
$secret = "3LxNHeLXEzJS";
//全てのリクエストヘッダーを取得
$headers = getallheaders();
//署名されたのを取得
$hubSignature = $headers['X-Hub-Signature'];
@rluisr
rluisr / SquidInfo.php
Last active Feb 4, 2016
Zabbixでsquidclient
View SquidInfo.php
<?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
S.M.A.R.T check for Zabbix
View smart.php
<?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 Jun 29, 2016
Notify you through Slack when SSH connection is established.
View rc
#!/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 Jul 29, 2016
【Node.js】 Check tracking status. This code supports 349 couriers. Notify with Twitter.
View app.js
/*
* 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 Oct 7, 2016
Shutdown All VMs. Using `virsh`.
View shutdown.sh
#!/bin/bash -e
virsh list --all | egrep '実行中|running' | awk '{print $2}' | xargs -t -I {} virsh shutdown {}
@rluisr
rluisr / check_cache.php
Created Jan 15, 2017
check wordpress WP_CACHE
View check_cache.php
<?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 Jan 25, 2017
Add service as systemd
View startup-api.service
[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
View stop.sh
#!/bin/bash
i=$1
shift
(sleep $i; kill $$) & exec "$@"
@rluisr
rluisr / reboot-all-lxc.sh
Created May 2, 2017
[Bash one liner] Reboot all LXC Container
View reboot-all-lxc.sh
for i in `(lxc-ls)`; do lxc-stop -n $i -r; done