Skip to content

Instantly share code, notes, and snippets.

@kou1okada
kou1okada / lambdatest.cpp
Created February 4, 2014 14:48
A practice for understanding the C++11 lambda.
#include <iostream>
template < typename Func >
inline void f_with_ref( Func &func )
{
func() ;
}
template < typename Func >
inline void f_with_cpy( Func func )
{
@kou1okada
kou1okada / check_imap_permanentflags.rb
Created February 7, 2014 13:15
check the PERMANENTFLAGS of a IMAP server.
#!/usr/bin/env ruby
require 'rubygems'
require 'highline'
require 'net/imap'
require 'optparse'
$config = {}
$config[:ssl] = true
opts = OptionParser.new
opts.on("-h", "--host HOST" ){|v| $config[:host] = v }
@kou1okada
kou1okada / monkeypatch.win32_registry.rb
Last active August 29, 2015 13:57
Monkey patch for 'win32/registry' of Ruby.
begin
Win32::Registry::Error.new(259)
rescue ArgumentError => e
if e.message == "invalid byte sequence in UTF-8"
class Win32::Registry::Error
FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall
def initialize(code)
@code = code
msg = "\0\0".force_encoding(Encoding::UTF_16LE) * 1024
len = FormatMessageW.call(0x1200, 0, code, 0, msg, msg.size, 0)
@kou1okada
kou1okada / ScanWithWindowsDefender.inf
Created April 30, 2014 15:16
Utilities for Microsoft Windows Defender
;------------------------------------------------------------------------------
; Scan with Windows Defender
; Copyright (c) 2014 Koichi OKADA
;
; License:
; The MIT Licensee.
; Reference:
; http://msdn.microsoft.com/en-us/library/windows/hardware/ff547433.aspx
; http://www.atmarkit.co.jp/ait/articles/1307/05/news055.html
;------------------------------------------------------------------------------
@kou1okada
kou1okada / ufs2info.rb
Last active August 29, 2015 14:08
A script for getting the UFS2 information.
#!/usr/bin/env ruby
# Copyright (c) 2014 Koichi OKADA. All right reserved.
# This script is distributed under the MIT license.
# http://www.opensource.org/licenses/mit-license.php
require "optparse"
SECTOR_SIZE = 512
UFS2_SBLK_LIST = [128, 16, 0, 512]
UFS2_SBLK_SIZE = 0x560
@kou1okada
kou1okada / mbr_test.asm
Created December 9, 2014 09:41
MBR test for PC/AT
;; MBR test for PC/AT
;;
;; @assemble
;; nasm mbr_test.asm -f bin -o mbr_test.bin
;;
;; @run
;; qemu-system-i386 -hda mbr_test.bin
;;
[bits 16]
@kou1okada
kou1okada / recoverstamp_for_302kc.sh
Last active August 29, 2015 14:11
Recover timestamp which is destroyed by the default file manager (com.kyocera.filemanager) of KYOCERA DIGNO T 302KC.
#!/usr/bin/env bash
#
# Recover timestamp which is destroyed by the default file manager (com.kyocera.filemanager) of KYOCERA DIGNO T 302KC.
# Copyright (c) 2014 Koichi OKADA. All rights reserved.
# This script is distributed under the MIT license.
# http://www.opensource.org/licenses/mit-license.php
#
[ -n "$DEBUG" ] && set -x
@kou1okada
kou1okada / fsicout.txt
Created March 20, 2015 15:47
F-Secure Linux Security Full Edition, result of create baseline for lineinteglity check.
This file has been truncated, but you can view the full file.
(Re)calculating baseline now
[Note] /bin/findmnt: Accept to baseline?
([Y]es,[N]o,[A]ll yes, [D]isregard new entries) [auto]
[Note] /bin/chgrp: Accept to baseline?
([Y]es,[N]o,[A]ll yes, [D]isregard new entries) [auto]
[Note] /bin/ln: Accept to baseline?
([Y]es,[N]o,[A]ll yes, [D]isregard new entries) [auto]
@kou1okada
kou1okada / ec-aes256.sh
Last active August 29, 2015 14:17
Encrypt file by AES256 and ssh ECDSA key pairs.
#!/usr/bin/env bash
#
# Copyright (c) 2015 Koichi OKADA. All rights reserved.
# This script is destributed under the MIT license.
#
if (( $# != 3 )); then
cat <<EOD
Usage: $(basename $0) key peerkey file
Encrypt file by AES256 and ssh ECDSA key pairs.
@kou1okada
kou1okada / hash_check.sh
Last active August 29, 2015 14:18
Read md5 and sha{1,224,256,384,512} sums from the FILEs and check them.
#!/usr/bin/env bash
#
# Copyright (c) 2015 Koich OKADA. All rights reserved.
# This script is distributed under the MIT license.
#
# dummy command for unknown sum.
# Usage: unknownsum
function unknownsum ()
{