Skip to content

Instantly share code, notes, and snippets.

View kazurof's full-sized avatar
🏠
Working from home

Kazuro Fukuhara kazurof

🏠
Working from home
View GitHub Profile
@kazurof
kazurof / Onishi-v2.ahk
Created January 22, 2024 02:06
https://0414.works/hairetu/ で公開されている、大西配列の AutoHotkey 向け設定ファイルの V2.0 対応版
SendMode "Input"
SetWorkingDir(A_ScriptDir)
-::/
w::l
e::u
r::,
t::.
@kazurof
kazurof / KodeinSample0.kt
Last active September 25, 2018 02:10
Kodein DI のDSLを紐解いてみる。 ref: https://qiita.com/kazurof/items/fe0348a252466c9bf7ca
package sample0
import org.kodein.di.Kodein
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.provider
import java.security.SecureRandom
import java.util.Random
fun main(args: Array<String>) {
import java.util.stream.Stream;
public class Zundoko {
public static void main(String args[]) {
StringBuilder sb = new StringBuilder();
Stream<String> stream = Stream.generate(() -> Math.random() > 0.5 ? "ズン" : "ドコ");
try {
stream.peek(s -> {
System.out.print(s);
sb.append(s);
@kazurof
kazurof / SampleClass.java
Last active February 22, 2016 05:23
Log4j 2でログ出力をテストするサンプルソース ref: http://qiita.com/kazurof/items/abbd42f11bfc125f3190
package org.example;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class SampleClass {
private static final Logger LOGGER = LogManager.getLogger(SampleClass.class);
void doSomething(String message) {
// Java8 & Log4j2として、ラムダを使うことでinfoか否かの判定をLog4j2に実施させる。
@kazurof
kazurof / Calc.java
Last active February 12, 2016 13:12
mockitoとJMockitについてのメモ ref: http://qiita.com/kazurof/items/1171c7e038050453c6c9
package org.example;
public class Calc {
int remainder(int dividend, int divisor) {
return dividend % divisor;
}
}
@kazurof
kazurof / Kantoka.java
Last active February 5, 2016 01:23
GradleでJavaアプリを実行する最小構成サンプル ref: http://qiita.com/kazurof/items/d5b00f7baf2b1699257d
package org.example;
import org.apache.commons.lang3.SystemUtils;
import java.util.Arrays;
public class Kantoka {
public static void main(String[] args) {
System.out.println("This is Kantoka");
System.out.println(args.length);
package org.example;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/sample")
public class EndPoint {
@kazurof
kazurof / BasicAuthComponent.php
Last active January 10, 2016 13:02
CakePHPでBASIC認証をするComponent ref: http://qiita.com/kazurof/items/94a07b672f062e2db568
<?php
class BasicAuthComponent extends Component {
public function startup(Controller $controller) {
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_USER'] !== BASIC_USERID || $_SERVER['PHP_AUTH_PW'] !== BASIC_PASSWD) {
$controller->autoRender = false;
$controller->response->header('WWW-Authenticate: Basic realm="Please enter your ID and password"');
$controller->response->statusCode(401);
$controller->response->send();
$this->_stop("id / password Required");
}
class Fraction {
/**
* 値を素因数分解して返します。
* 素数を x で連結する表記です。
* 10 => 2x2x5x5
* */
static String factorize(long val) {
if(val == 1L){
return "1";
}
@kazurof
kazurof / POHLite-kirishima-awk.java
Last active August 29, 2015 14:06
sample code for https://paiza.jp/poh/kirishima with awk over Java.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
public class Main {
public static void main(String[] args) throws Exception {
StringBuilder script = new StringBuilder();