Skip to content

Instantly share code, notes, and snippets.

View KenjiOhtsuka's full-sized avatar
👍
Hello, World!

Kenji Otsuka KenjiOhtsuka

👍
Hello, World!
View GitHub Profile
@KenjiOhtsuka
KenjiOhtsuka / FileSystem.kt
Created May 21, 2018 02:12
Get Children in File System with Kotlin
/**
* Sample code to handle file system
*/
import java.io.File
/**
* Get all sub file objects in the directory.
*/
fun sample1(path: String): Array<File> {
@KenjiOhtsuka
KenjiOhtsuka / AWSS3Client.kt
Created May 21, 2018 07:50
List S3 Object with Kotlin
// Gradle dependencies section must contains following jar
// compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.319'
val credential = BasicAWSCredentials(
"ACCESSKEY",
"SECRETKEY")
// building s3client
// I set Region to `Regions.AP_SOUTH_1`
// because when I used other region, error rose.
@KenjiOhtsuka
KenjiOhtsuka / search.c
Last active June 11, 2018 12:24
C Program to search all instance variables in a Ruby file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
#define PATTERN_COUNT 1
#define WORD_MAX_LENGTH 30
#define FILE_MAX_SIZE 100000
#define WORD_MAX_COUNT 10000
@KenjiOhtsuka
KenjiOhtsuka / generate_password.html
Created June 12, 2018 06:09
HTML for Password Generation
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p><strong>パスワードジェネレータ</strong>です。</p>
<p>"記号を含める"を YES にすると、括弧などの記号も含めてパスワードを生成します。数字は半角で入力してネ!</p>
<form>
<p>
pragma solidity ^0.4.23;
// SafeMath
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
@KenjiOhtsuka
KenjiOhtsuka / file0.txt
Last active November 14, 2018 09:47
Stampery Merkle Tree Algorithm PROOFS VERIFICATION の丁寧な説明 ref: https://qiita.com/KenjiOtsuka/items/6f554f8691c9f7998d2b
o
/ \
o o
| | | |
0 1 2 3
@KenjiOhtsuka
KenjiOhtsuka / sql.c
Created August 15, 2018 08:55
C code to connect to PostgreSQL DB
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <postgresql/libpq-fe.h>
#include <postgresql/9.5/server/postgres.h>
struct DbConfig {
char host[30];
char dbName[30];
char userName[30];
@KenjiOhtsuka
KenjiOhtsuka / file0.txt
Last active September 2, 2018 01:22
MYSQL: PHP から認証できない場合 ref: https://qiita.com/KenjiOtsuka/items/8e520f53df2ae84f75e9
PDOException in Connector.php line 55:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
@KenjiOhtsuka
KenjiOhtsuka / Kotlin
Last active May 31, 2020 01:17
Java で SSL の証明書エラーを解決/回避して HTTPS で接続する方法 ref: https://qiita.com/KenjiOtsuka/items/0bf38365b8df6e08af18
package com.example.app
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
import java.security.cert.X509Certificate
import javax.net.ssl.*
import java.security.cert.CertificateException
@KenjiOhtsuka
KenjiOhtsuka / sample.kt
Created October 30, 2018 18:40
Kotlin prepared statement (SQL)
package com.improve_future.sample
import java.io.Closeable
import java.sql.DriverManager
import java.sql.Statement
import java.text.SimpleDateFormat
class Connection(private val coreConnection: java.sql.Connection) :
java.sql.Connection by coreConnection, Closeable {