Skip to content

Instantly share code, notes, and snippets.

@yusukemihara
yusukemihara / dance.rb
Created September 2, 2014 06:40
dance.rb
# encoding:utf-8
require 'serialport'
$serial_port = '/dev/ttyUSB0'
$serial_baudrate = 9600
$serial_databit = 8
$serial_stopbit = 1
$serial_paritycheck = 0
sp = SerialPort.new($serial_port, $serial_baudrate, $serial_databit, $serial_stopbit, $serial_paritycheck)
@yusukemihara
yusukemihara / curlpkcs11.c
Created August 1, 2014 02:21
perform HTTPS GET on ssl client verification using curl,OpenSSL ENGINE pkcs11 and libp11
#if 0
#!/bin/bash
src=$0
obj=${src%.*}
gcc -g -Wl,--no-as-needed `pkg-config --cflags --libs libcurl libssl libp11` -o $obj $src
exit
#endif
/* perform HTTPS GET on ssl client verification using curl,OpenSSL ENGINE pkcs11 and libp11
*
@yusukemihara
yusukemihara / TestPKCS11.java
Last active October 11, 2022 13:54
perform HTTPS GET on SSL client verification using Java PKCS#11
/*
* perform HTTPS GET on SSL client verification using Java PKCS#11
*
* requirement:
* * PKCS#11 enable security token
* * the token has stored cert and key for ssl client verification,and ca cert
* PKCS#11 library(.dll or .so) for the token
*
* usage:
* java -cp . -D java.security.debug=sunpkcs11 TestPKCS11 https://www.example.com/
@yusukemihara
yusukemihara / testjson.c
Last active December 24, 2015 15:19
% ./testjson.c # コンパイル % ./testjson /usr/lib/jma-receipt/record/M00.rec # 実行
#if 0
#!/bin/bash
src=$0
obj=${src%.*}
gcc -g -Wl,--no-as-needed `pkg-config --cflags --libs libmondai` -o $obj $src
$obj
exit
#endif
#include <stdio.h>
filetype indent off
"set sw=2 expandtab
set tabstop=4
set ignorecase
set noautoindent
set fileencoding=utf-8
set fileencodings=utf-8,euc-jp,iso-2022-jp
inoremap <C-h> <Left>
inoremap <C-j> <Down>
@yusukemihara
yusukemihara / lp64.c
Last active December 16, 2015 07:48
uint64_tでのntohl、htonl
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <memory.h>
#ifdef __LP64__
typedef long Obj;
#else
@yusukemihara
yusukemihara / gist:5297487
Created April 3, 2013 00:33
nestfulでSSLクライアント認証する。
ops = {
:ssl_options => {
:use_ssl => true,
:vefify_mode => OpenSSL::SSL::VERIFY_PEER,
:cert => OpenSSL::X509::Certificate.new(File.read(CERT_FILE)),
:key => OpenSSL::PKey::RSA.new(File.read(KEY_FILE)),
:ca_file => CA_FILE
}
}
ops[:params] = {:id => 1, :data => 2}
@yusukemihara
yusukemihara / barby.rb
Created February 4, 2013 07:52
barbyでバーコード作ってみよう
require 'barby'
require 'barby/outputter/rmagick_outputter'
barcode = Barby::Code128B.new(ARGV[1])
File.open(ARGV[0],"w"){|f|
f.write barcode.to_png(:height=>32,:margin=>1)
}
@yusukemihara
yusukemihara / barcode.c
Last active December 12, 2015 03:18
libbarcodeとlibpng12を使ってバーコードのpngを作成するのだ ubuntu>=10.04
#if 0
#!/bin/bash -x
src=$0
out=${src%.*}
obj=$out.o
gcc -g -Wl,--no-as-needed `pkg-config --cflags --libs libpng12 ` -lm -c $src
gcc -g -Wl,--no-as-needed `pkg-config --cflags --libs libpng12 ` -lm -o $out $obj /usr/lib/libbarcode.a
$out
rm $obj $out
exit
@yusukemihara
yusukemihara / macromacro.c
Created January 31, 2013 01:19
C言語。マクロの中でマクロが使えるのか?テスト。結論=使える。
#if 0
#!/bin/bash
src=$0
obj=${src%.*}
gcc -o $obj $src
$obj
exit
#endif
#define PRICE "99"