Skip to content

Instantly share code, notes, and snippets.

@xhiroga
xhiroga / Fib7.java
Created November 28, 2017 22:36
Java7で実装されたフォーク/ジョインFWを使ったフィボナッチ数列の計算プログラムです。
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.ForkJoinPool;
public class Fib7 extends RecursiveTask<Integer>{
private final int n;
Fib7(int n){
this.n = n;
}
@xhiroga
xhiroga / Fib5.java
Created November 28, 2017 23:16
Java5で実装されたExecutorServiceを、newCachedThreadPool()で作って利用するプログラムです。書き方が悪いのか、簡単にOOMEになります...
import java.util.*;
import java.util.concurrent.*;
public class Fib5 {
private ExecutorService exec = Executors.newCachedThreadPool();
public class Task implements Callable<Integer> {
private final int n;
@xhiroga
xhiroga / Fib.py
Created November 29, 2017 23:03
黄金比のグラフを出力してくれるやつ
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
def main():
n = 30
fib_list = []
rate_list = []
@xhiroga
xhiroga / Csv.java
Last active December 4, 2017 14:36
Csvの中身を読み取って書き出すシンプルなプログラム。練習用だよ。
import java.io.*;
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.csv.CSVFormat;
public class Csv{
public static void main(String[] args){
try{
String homeDir = System.getenv("HOME");
Reader reader = new FileReader(homeDir + "/dev/lrn/java/file/read.csv");
FileWriter writer = new FileWriter(homeDir + "/dev/lrn/java/file/write.csv");
@xhiroga
xhiroga / km.py
Created December 9, 2017 13:40
世界中のUFO目撃情報をk-mean法でクラスタリング
# coding:utf-8
from sklearn import cluster, datasets
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# このデータが曲者で、数値データの中に英字や記号が混ざってた
df = pd.read_csv("scrubbed.csv")
@xhiroga
xhiroga / IOByExec.java
Created December 27, 2017 21:24
20171227.初めてのマルチスレッド@jjugナイトセミナー プレゼン用ソースコード
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
public class IOByExec implements Runnable{
private ExecutorService exec = Executors.newCachedThreadPool();
private String name;
private int count;
@xhiroga
xhiroga / striped-2span-table.html
Created January 31, 2018 11:44
1行が2段組でも縞々に表示するテーブルのサンプル
<!DOCTYPE html>
<html>
<head>
<title>1行が2段組のテーブルを縞々に表示する</title>
<style type="text/css">
.table-striped-2span tbody tr:nth-of-type(4n+1), .table-striped-2span tbody tr:nth-of-type(4n+2) {
background-color: #c0c0c0;
}
</style>
@xhiroga
xhiroga / tweetdeck_custom_css_for_ctf18.css
Created May 27, 2018 13:13
CIVIC TECH FORUM 2018用のTweetDeckのカスタマイズ設定
.column{
font-size:42px;
width:100%;
}
.item-box{
background-color:white;
}
.js-column-header{
display:none;
}
@xhiroga
xhiroga / python.json
Created August 11, 2018 02:08
Snipets File
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@xhiroga
xhiroga / cfn.sh
Created November 3, 2018 22:46
CloudFomationの勉強を円滑にするための便利スクリプト
cmd=$1
stack_name=$2
if [ $cmd = "create" ]; then
case $3 in
"") echo "Error: Please give a template file path!"; exit 0;;
/*) absolute=$3 ;;
*) absolute=$PWD/$3 ;;
# S3にはこれから対応する、かも
esac