Skip to content

Instantly share code, notes, and snippets.

View moznion's full-sized avatar

moznion moznion

View GitHub Profile
package net.moznion.jesque.worker;
import lombok.extern.slf4j.Slf4j;
import net.greghaines.jesque.Config;
import net.greghaines.jesque.ConfigBuilder;
import net.greghaines.jesque.Job;
import net.greghaines.jesque.client.Client;
import net.greghaines.jesque.client.ClientImpl;
import net.greghaines.jesque.worker.JobFactory;
import net.greghaines.jesque.worker.MapBasedJobFactory;
package net.moznion;
import me.geso.nanobench.Benchmark;
import me.geso.nanobench.Benchmark.Bench;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class BenchmarkRandom {
public static class RandomNumberGenerator extends Thread {
enum LowerCaseLetter {
a, b, c;
private static final List<LowerCaseLetter> VALUES = Arrays.asList(values());
private static final int SIZE = VALUES.size();
private static final Random RANDOM = new Random();
public static String getRandomLetter() {
return VALUES.get(RANDOM.nextInt(SIZE)).toString();
}
}
package me.geso.routes;
import java.util.LinkedHashMap;
public class PathRouteBench {
public void benchPathRoute() {
for (int i = 0; i < 1_000_000; ++i) {
PathRoute<String> route = new PathRoute<String>("/foo/*", "Detail");
LinkedHashMap<String, String> captured = new LinkedHashMap<>();
boolean matched = route.match("/foo/bar/baz", captured);
import java.util.Formatter;
public class Bench {
private String fileName = "foo.java";
private String className = "class.dayo";
private String methodName = "methodDayo";
private int lineNumber = 42;
public void benchStringBuilder() {
for (int i=0; i<1_000_000; ++i) {
.DEFAULT_GOAL := watch
thesis.dvi: thesis.tex
platex thesis.tex
thesis.pdf: thesis.dvi
dvipdfmx -f texfonts.map thesis.dvi
watch:
./script/watcher --dir ./thesis.tex -- make thesis.pdf
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my ($old_file, $new_file) = @ARGV;
if (!defined $old_file || !defined $new_file) {
die "You must give two file names via command line argument";
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use File::chdir;
use File::Temp qw/tempdir/;
use File::Copy qw/move/;
use Text::Iconv;
use Excel::Writer::XLSX;
orig_program_name = $0
(1..100).each do |i|
# do something
sleep 0.1
# ここでプログラム名上書きして進捗を追加
$0 = "#{orig_program_name}(#{i}%)"
end
my $lpnum = 1;
for ($i++; $token = $tokens->[$i]; $i++) {
$token_type = $token->{type};
if ($token_type == LEFT_PAREN) {
$lpnum++;
}
elsif ($token_type == RIGHT_PAREN) {
last if --$lpnum <= 0 ;
}
# ここでてきとうに処理する