Skip to content

Instantly share code, notes, and snippets.

View ozuma's full-sized avatar

Osumi, Yusuke ozuma

View GitHub Profile
@ozuma
ozuma / nochunk.cgi
Created July 24, 2013 05:30
Suppress "Transfer-Encoding: chunked" header and chunked body in CGI. (Apache, Perl)
#!/usr/bin/perl
use strict;
use warnings;
my $body = <<"EOM";
<html>
<head>
<title>title</title>
</head>
@ozuma
ozuma / random_string.pl
Last active December 20, 2015 08:48
Create Random Strings in Perl.
#!/usr/bin/perl
use strict;
use warnings;
my $rand_str = get_random_str(10);
print "$rand_str\n";
sub get_random_str {
my $length = shift;
@ozuma
ozuma / sprintf.sql
Created July 29, 2013 10:16
How to sprintf() in MySQL.
UPDATE userinfo SET view_id=LPAD(lower(hex(status)), 5, '0');
+------------+--------+------------+---------+
| userid | status | password | view_id |
+------------+--------+------------+---------+
| a121 | 146 | aaaa | 00092 |
| a122 | 149 | aaaa | 00095 |
| a123 | 150 | aaaa | 00096 |
| a124 | 151 | aaaa | 00097 |
| a125 | 155 | aaaa | 0009b |
@ozuma
ozuma / send_udp.c
Created August 14, 2013 06:28
Send a UDP Packet. (C Code)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
main()
{
int sock;
struct sockaddr_in addr;
@ozuma
ozuma / send_packet.pl
Created August 14, 2013 07:14
Test tool: Send a raw TCP or UDP packet. (Perl)
#!/usr/bin/perl
use strict;
use warnings;
use Socket;
my $iaddr = inet_aton("192.168.1.1");
my $port = 80;
#send_tcp($iaddr, $port);
@ozuma
ozuma / Packet::Simple.pm
Created August 14, 2013 07:51
Send a raw TCP or UDP packet. (Perl Module)
# use lib qw(./lib);
# use Packet::Simple;
# my $obj = Packet::Simple->new("192.168.1.2", 50001);
# $obj->send_tcp();
package Packet::Simple;
use strict;
use warnings;
our $VERISON = '0.01';
@ozuma
ozuma / process_chk.sh
Created September 7, 2013 02:38
Watch a number of processes.
#!/bin/sh
process="/usr/sbin/httpd"
count=$(ps axww -o command | grep "$process" | grep -v grep | wc -l)
if [ $count = 0 ]; then
echo "[ERROR] Process not found: $process"
exit 1
elif [ $count -lt 1 ]; then
echo "[ERROR] Number of processes are low: $process"
@ozuma
ozuma / getcert.sh
Created October 25, 2013 05:29
Get a Modulus of SSL Certificate by https prototocol.
#!/bin/sh
while read hostname
do
{
echo -n ${hostname},
openssl s_client -connect ${hostname}:443 < /dev/null | openssl x509 -modulus -noout
} >> result.txt
done < hostlist
@ozuma
ozuma / sendmail.pl
Created October 28, 2013 11:05
Sample Script: Send an e-mail with Net::SMTP (Perl)
#!/usr/bin/perl -w
use strict;
use Jcode;
use Net::SMTP;
use MIME::Base64 qw(encode_base64);
local $/;
my $DEBUG = 0;
@ozuma
ozuma / proxy_ajp.conf
Created October 31, 2013 07:03
Apache => Tomcat (AJP) httpd.conf sample.
# httpd.conf
#
# Apache -> Tomcat (AJP) sample config.
# ワーカーに重なりがある場合、前方一致で最初にマッチしたルールが勝つ。
# そのためProxyPassの設定は、「URLが長い順」に書かないといけない。
# http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
#-- Valid Setting --------------------------------------------------
ProxyPass /service-test/ balancer://service-test/