Skip to content

Instantly share code, notes, and snippets.

View lostsnow's full-sized avatar
👻
nil

lostsnow lostsnow

👻
nil
View GitHub Profile
#!/bin/sh
HOST=$(hostname | awk -F'.' '{print $1}')
IDC=$(hostname | awk -F'.' '{print $3}')
SYSTEM_LOAD=$(awk '{print $1}' /proc/loadavg)
SYSTEM_MEMORY=$(free -m | grep 'buffers/cache' | awk '{print $NF}')
NGINX_CONNECTIONS=$(curl -s http://127.0.0.1/server-status | head -n 1 | awk '{print $NF}')
REDIS_CONNECTIONS=$(/usr/local/redis/bin/redis-cli info | grep connected_clients | awk -F: '{print $NF}' | sed 's/.$//')
@lostsnow
lostsnow / redmine-issue-css-by-status.css
Created February 25, 2013 04:20
redmine issue css by status
/* new */
tr.odd.status-1, table.list tbody tr.odd.status-1:hover { color: #900; }
tr.odd.status-1 { background: #ffc4c4; }
tr.even.status-1, table.list tbody tr.even.status-1:hover { color: #900; }
tr.even.status-1 { background: #ffd4d4; }
tr.status-1 a, tr.status-1:hover a { color: #900; }
tr.odd.status-1 td, tr.even.status-1 td { border-color: #ffb4b4; }
/* assigned / in progress */
tr.odd.status-2, table.list tbody tr.odd.status-2:hover { color: #990; }
@lostsnow
lostsnow / fastdfs_monitor.sh
Last active December 14, 2015 21:09
Monitor FastDFS status Author: xy19900828@gmail.com
#!/bin/bash
#
#---------------------FastDFS monitor------------------------
#------------------------------------------------------------
# This scripts use to monitor the fastdfs's status. with standard output.
# you can run it in this way to let it loop 3 times with 5 seconds break:
# ./fdfs_monitor.sh 5 3
#
# or just run it to loop for 10 years with 3 seconds break.
# ./fdfs_monitor.sh
#!/bin/sh
while true;
do
if test -n "`file /tmp/Flash*|grep \"Macromedia Flash Video\\|MPEG v4\"`";then
gnome-screensaver-command -p
fi
sleep 30
done
<?php
/**
* input:
* $arr = array(
* 'a' => array(
* 'b' => array(
* 'c' => 'bar'
* ),
* 'x' => 'i',
* )
@lostsnow
lostsnow / exfile-test
Last active April 10, 2017 14:48
Inotify + rsync script
- *.log
- *.swp
#!/bin/sh
#
# Script to prepare and restore full and incremental backups created with innobackupex-runner.
#
# This script is provided as-is; no liability can be accepted for use.
#
INNOBACKUPEX=innobackupex-1.5.1
INNOBACKUPEXFULL=/usr/bin/$INNOBACKUPEX
TMPFILE="/tmp/innobackupex-restore.$$.tmp"
#!/bin/bash
# backup MySQL databases
# author: lostsnow@gmail.com
# backup directory
backup_parent_dir="/opt/backups/mysql"
mysql_dir=/usr/local/mysql
# MySQL settings
mysql_host=$1
<?php
/**
* CVE-2013-4547
* http://mailman.nginx.org/pipermail/nginx-announce/2013/000125.html
* author lostsnow@gmail.com
*/
$host = 'x.com';
$fp = fsockopen($host, 80, $errno, $errstr);
@lostsnow
lostsnow / sorting option select jQuery
Last active January 2, 2016 19:19 — forked from boy3vil/sorting option select jQuery
add chinese char support
<html>
<head>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('button').click(function() {
var options = $('select.whatever option');
var arr = options.map(function(_, o) {