This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
# | |
# 指定された日付が、その月において何週目にあたるのかを計算し、返却します。 | |
# | |
# 週始まりは月曜です。初週を 1 としています。 | |
# | |
def week_of_month(date) | |
first_week = (date - (date.day - 1)).cweek | |
this_week = date.cweek |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.PrintStream; | |
import java.util.Base64; | |
/** | |
* Java 8 より導入された java.util.Base64 の利用デモ。 | |
*/ | |
public class Base64Demo { | |
private static final PrintStream o = System.out; | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.core.JsonGenerator; | |
import com.fasterxml.jackson.core.PrettyPrinter; | |
import java.io.IOException; | |
import java.util.Arrays; | |
import java.util.Stack; | |
/** | |
* Google Chrome における JSON.stringify() に近い pretty print を実現します。 | |
* <p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.Properties; | |
/** | |
* UTF-8 エンコーディングされたプロパティファイルを {@link Properties} クラスで取り扱う。 | |
*/ | |
public class PropertiesWithUtf8 { | |
static Properties loadUtf8Properties(String resourceName) throws IOException { | |
try (InputStream is = PropertiesWithUtf8.class.getResourceAsStream(resourceName); | |
InputStreamReader isr = new InputStreamReader(is, "UTF-8"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.util.Locale; | |
import java.util.PropertyResourceBundle; | |
import java.util.ResourceBundle; | |
/** | |
* UTF-8 エンコーディングされたプロパティファイルを {@link ResourceBundle} クラスで取り扱う。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.Gson; | |
import org.apache.http.HttpEntity; | |
import org.apache.http.client.methods.CloseableHttpResponse; | |
import org.apache.http.client.methods.HttpPost; | |
import org.apache.http.entity.StringEntity; | |
import org.apache.http.impl.client.CloseableHttpClient; | |
import org.apache.http.impl.client.HttpClientBuilder; | |
import java.io.BufferedReader; | |
import java.io.IOException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedInputStream; | |
import java.io.BufferedOutputStream; | |
import java.io.DataInputStream; | |
import java.io.DataOutputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Collection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Apriori algorithm の実装です | |
# | |
# http://en.wikipedia.org/wiki/Apriori_algorithm の擬似コードと | |
# http://www.codeproject.com/Articles/70371/Apriori-Algorithm を | |
# 参考にしています | |
require 'set' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.k11i.hoge; | |
import java.util.Arrays; | |
import java.util.EnumMap; | |
import java.util.List; | |
import java.util.Map; | |
import me.k11i.hoge.HtmlCharsetDetector.FiniteStateMachine.State; | |
import static me.k11i.hoge.HtmlCharsetDetector.FiniteStateMachine.State.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.apache.spark.ml.evaluation | |
import org.apache.commons.math3.util.FastMath | |
import org.apache.spark.ml.param.ParamMap | |
import org.apache.spark.ml.param.shared.{HasLabelCol, HasProbabilityCol} | |
import org.apache.spark.ml.util.{Identifiable, SchemaUtils} | |
import org.apache.spark.mllib.linalg.{Vector, VectorUDT} | |
import org.apache.spark.sql.types.DoubleType | |
import org.apache.spark.sql.{DataFrame, Row} |
NewerOlder