Skip to content

Instantly share code, notes, and snippets.

@xhiroga
xhiroga / gist:889dcdd922c6b9a44a387084eb4b2d83
Created June 20, 2019 23:52
Pick an element from an array every day, with 3 conditions. 1. while a loop, the element should not be same. 2. for every loop, order should be random. 3. no external memory.
Pick an element from an array every day, with 3 conditions. 1. while a loop, the element should not be same. 2. for every loop, order should be random. 3. no external memory.
ある配列から、毎日要素を取り出したい。ただし、配列が一周するまでは要素が重複してはいけず、また、毎周の順番が固定でもいけない。
an array.
ある配列がある。
```
["apple", "banana", "carrot"]
```
@xhiroga
xhiroga / versionup.js
Created December 8, 2018 23:35
Upgrade Expo App version
// Put this file on top directory in your expo project.
APP_JSON_FILE = 'app.prod.json'
var app_json = require(APP_JSON_FILE)
version = app_json.expo.version
console.log(`Latest version: ${version}`)
match = /([0-9]+\.[0-9]+\.)([0-9]+)/.exec(version)
major_minor_version = match[1]
patch_version = match[2]
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 = []