Skip to content

Instantly share code, notes, and snippets.

View ozuma's full-sized avatar

Osumi, Yusuke ozuma

View GitHub Profile
@ozuma
ozuma / postdump.cgi
Last active December 17, 2015 03:48
Perl CGI: Dump POST(HTTP) body to a temporary file.
#!/usr/bin/perl
use strict;
my $postdata;
read(STDIN, $postdata, $ENV{'CONTENT_LENGTH'});
my $time = time();
open(FP, ">/var/tmp/post-${time}.dat");
print FP $postdata;
close(FP);
@ozuma
ozuma / post_rawcontent.pl
Created May 9, 2013 13:13
POST(HTTP) raw content body.
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $url = "http://localhost/~ozuma/postdump.cgi";
my $post_body = <<POST_XML;
<?xml version="1.0" encoding="utf-8"?>
<sample>
@ozuma
ozuma / response_headers_asstring.pl
Created May 9, 2013 13:58
Get HTTP Response Headers as string.
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:20.0) Gecko/20100101 Firefox/20.0");
my $req = HTTP::Request->new(GET => 'http://www.example.com/');
my $res = $ua->simple_request($req);
@ozuma
ozuma / response_headers_list.pl
Created May 9, 2013 13:59
GET HTTP Response Headers as Array.
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:20.0) Gecko/20100101 Firefox/20.0");
my $req = HTTP::Request->new(GET => 'http://www.example.com/');
my $res = $ua->simple_request($req);
@ozuma
ozuma / send_udp.rb
Created May 15, 2013 02:18
Send a UDP test packet.
#!/usr/bin/ruby
require "socket"
udp = UDPSocket.open()
sockaddr = Socket.pack_sockaddr_in(53, "192.168.0.1")
udp.send("HELLO", 0, sockaddr)
udp.close
@ozuma
ozuma / recv_udp.rb
Last active December 17, 2015 15:29
Receive a UDP Packet. (As server)
#!/usr/bin/ruby
require "socket"
udp = UDPSocket.open()
udp.bind("0.0.0.0", ARGV[0])
p udp.recv(65535)
udp.close
@ozuma
ozuma / htpasswd
Last active December 17, 2015 19:19
Create Apache htpasswd (encoded with MD5/SHA1)
# Create File
## Default
$ htpasswd -c .htpasswd guest
$ htpasswd -d -c .htpasswd guest # 最近のは-dが必要
# cryptはパスワード8文字
New password:
Re-type new password:
Adding password for user guest
$ cat .htpasswd
guest:AB5mCJkOABnpY
@ozuma
ozuma / PrivateMethod.pm
Created June 28, 2013 08:09
How to create a private method in Perl.
#!/usr/bin/perl
# It looks like magic, but in fact, it's mere random number.
package Magic;
use strict;
use warnings;
sub new {
my $pkg = shift;
@ozuma
ozuma / exif.pl
Created July 10, 2013 10:43
How to show Exif Informations from JPEG file.
#!/usr/bin/perl
use strict;
use warnings;
use Image::ExifTool;
use Data::Dumper;
my $filename = $ARGV[0];
my $ext = new Image::ExifTool;
my $exif = $ext->ImageInfo($filename);
@ozuma
ozuma / UserAgent.md
Last active December 19, 2015 19:29
UserAgent String List
  • Windows 7 + IE8
    • Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C)
  • Windows 7 + Firefox 22
    • Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0
  • WindowsXP Home + IE8
    • Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)