Skip to content

Instantly share code, notes, and snippets.

/**
*
* Generate v4 UUID
*
* Version 4 UUIDs are pseudo-random.
*/
function uuid() {
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
@hmkz
hmkz / yum.conf
Created December 9, 2013 02:14
centos3.9 /etc/yum.conf
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
installonlypkgs=kernel kernel-smp kernel-hugemem kernel-enterprise kernel-debug kernel-unsupported kernel-smp-unsupported kernel-hugemem-unsupported
tolerant=1
exactarch=1
[base]
function calcDateFromDuration() {
var today = parseInt(new Date()/1000)
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ["2F-12-18-1", "2F-12-18-2"]
for (var sheet_idx in sheets) {
//Browser.msgBox(sheet_idx);
var sheet = ss.getSheetByName(sheets[sheet_idx])
var range = sheet.getRange("I2:I60")
var values = range.getValues()
@hmkz
hmkz / linecount.py
Created December 24, 2013 01:57
標準入力から重複した行を計算して出力する。
#!/usr/bin/env python
import sys
tmp = {}
for line in sys.stdin:
line = line.strip()
if line not in tmp:
tmp[line] = 0
else:
tmp[line] += 1
@hmkz
hmkz / gist:7886793
Created December 10, 2013 07:08
apache 1.3.42 + mod_fastcgi + php-fpm(5.4)
## apache 1.3.42 + mod_fastcgi + php-fpm(5.4)
LoadModule fastcgi_module libexec/mod_fastcgi.so
AddModule mod_fastcgi.c
## FastCGI
Alias /php5.fcgi /usr/bin/php-cgi
FastCGIConfig -initial-env -autoUpdate -idle-timeout 120 -killInterval 3600 -maxClassProcesses 3 -maxProcesses 15
FastCGIExternalServer /usr/bin/php-cgi -socket /tmp/php-fpm.sock -pass-header Authorization
Action application/x-httpd-php /php5.fcgi
AddType application/x-httpd-php .php .php5
@hmkz
hmkz / ipcount.py
Last active December 29, 2015 12:09
1行に1IPアドレスが記載されているテキストファイルからIPアドレス毎の出現回数を計算する。 IPアドレスからWhoisを通して国名とIPレンジを調べる
#!/usr/bin/env python3
# -*- encoding: utf8 -*-
from ipwhois import IPWhois
from IPy import IP
fobj = open("iplist.txt", 'r')
counter = {}
for line in fobj:
line = line.rstrip()
@hmkz
hmkz / cpanel_iptables.conf
Created November 21, 2013 03:28
/etc/sysconfig/iptables
# Generated by iptables-save v1.4.7 on Thu Nov 21 12:27:09 2013
*filter
:INPUT ACCEPT [1078:159417]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [753:164197]
:acctboth - [0:0]
:cP-Firewall-1-INPUT - [0:0]
-A INPUT -j cP-Firewall-1-INPUT
-A INPUT -j acctboth
-A FORWARD -j cP-Firewall-1-INPUT
#!/usr/bin/perl
# The above line may need to be changed to point at your version of Perl
#
# This script attempts to find malicious files/scripts on your machine.
# It specifically looks for spambots that we're aware of, as well
# as "suspicious" constructs in various scripting languages.
#
# Normally it should be run as root.
#
# By default, findbot.pl scans the directories /tmp, /usr/tmp, /home and
{
// The tab key will cycle through the settings when first created
// Visit http://wbond.net/sublime_packages/sftp/settings for help
// sftp, ftp or ftps
"type": "sftp",
"sync_down_on_open": true,
"sync_same_age": true,
@hmkz
hmkz / convert_datetime.py
Last active December 28, 2015 20:19
年月日,時分秒など日本語で書かれた日付をyyyy-MM-DD HH:mm:ssに変換する。
#!/usr/bin/env python
# -*- encoding: utf8 -*-
import re
date_jpn = "2013年11月7日 08時43分52秒"
r = re.compile("(.*)年(.*)月(.*)日 (.*)時(.*)分(.*)秒")
# 抽出した値はタプルになっているので、タプルを配列に変換
dt = list(r.search(date_jpn).groups())