Skip to content

Instantly share code, notes, and snippets.

View krhitoshi's full-sized avatar

Hitoshi Kurokawa krhitoshi

View GitHub Profile
#!/usr/bin/env ruby
require 'open-uri'
uri = "http://localhost/nginx_status"
lines = nil
open(uri) do |f|
lines = f.read.split("\n")
end
#!/usr/bin/env ruby
# Xen
#mac = [0x00, 0x16, 0x3e, Random.rand(0x7f), Random.rand(0xff), Random.rand(0xff)]
# QEMU or KVM
mac = [0x52, 0x42, 0x00, Random.rand(0x7f), Random.rand(0xff), Random.rand(0xff)]
puts (["%02x"] * 6).join(":") % mac
@krhitoshi
krhitoshi / reverse
Last active December 18, 2015 13:39
#!/usr/bin/env ruby
require 'socket'
def get_name(addr)
info = Socket.getnameinfo(Socket.sockaddr_in('80', addr))
info[0]
end
ADDR_REG_EXP = /\b((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\b/
diff --git create-mailbox.php create-mailbox.php
index c8ec29a..66d6147 100644
--- create-mailbox.php
+++ create-mailbox.php
@@ -131,6 +131,16 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
}
}
+ $min_length = $CONF['min_password_length'];
+ if($min_length > 0 && strlen($fPassword) < $min_length) {
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
#
# Do NOT simply read the instructions in here without understanding
@krhitoshi
krhitoshi / bcrypt.php
Created November 18, 2012 12:23
PHP script to create bcrypt hash password
#!/usr/bin/php
<?php
function create_salt(){
$salt_source = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$num = strlen($salt_source)-1;
$salt = "";
for($i=0; $i<22; $i++){
$index = mt_rand(0, $num);
@krhitoshi
krhitoshi / doveadm_usage.txt
Created October 17, 2012 10:11
doveadm usage
usage: doveadm [-Dv] [-f <formatter>] <command> [<args>]
altmove [-u <user>|-A] [-S <socket_path>] <search query>
auth [-a <auth socket path>] [-x <auth info>] <user> [<password>]
config [doveconf parameters]
director add|flush|map|remove|status
dump [-t <type>] <path>
expunge [-u <user>|-A] [-S <socket_path>] <search query>
fetch [-u <user>|-A] [-S <socket_path>] <fields> <search query>
force-resync [-u <user>|-A] [-S <socket_path>] <mailbox>
@krhitoshi
krhitoshi / datetime_ext.rb
Created October 10, 2012 04:44
DataMapper MySQL bug by '0000-00-00 00:00:00'
class DateTime
class << self
alias org_new new
def new(year = -4712, mon = 1, mday = 1, hour = 0, min = 0, sec = 0, offset = 0, start = Date::ITALY)
if year == 0
nil
else
org_new(year, mon, mday, hour, min, sec, offset, start)
end
@krhitoshi
krhitoshi / error_messages.txt
Created October 8, 2012 05:56
Error messages
You're running a version of ruby with no Readline support
Please `gem install rb-readline` or recompile ruby --with-readline.
@krhitoshi
krhitoshi / init.el
Created July 17, 2011 08:02
Emacs configure file
;; PATH
(setq exec-path (cons "/opt/local/bin" exec-path))
(setenv "PATH"
(concat '"/opt/local/bin:" (getenv "PATH")))
;; load-path
(add-to-list 'load-path "~/.emacs.d/")
(add-to-list 'load-path "~/.emacs.d/share/emacs/site-lisp/")
(add-to-list 'load-path "~/.emacs.d/ruby/")