Skip to content

Instantly share code, notes, and snippets.

@tksmaru
tksmaru / MainActivity.java
Created August 6, 2015 22:40
Android API levelを意識したNotificationの実装例
package com.example.maruyama.helloandroid5;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
@tksmaru
tksmaru / ReportAccess.java
Created February 12, 2012 12:23
SRM241 div1-score250
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
//SRM241
public class ReportAccess {
public String[] whoCanSee(String[] userNames, String[] allowedData,
String[] reportData) {
@tksmaru
tksmaru / ReportAccess.java
Created February 13, 2012 00:16
SRM241 div1-score250 もう一度考えてみた。
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
//SRM241
public class ReportAccess {
public String[] whoCanSee(String[] userNames, String[] allowedData,
String[] reportData) {
@tksmaru
tksmaru / TestExtendedFor.java
Created February 29, 2012 15:17
Testing extended for-loop
import java.util.ArrayList;
import java.util.List;
/**
* 拡張for文のテスト
*
* @author tksmaru
*
*/
public class TestExtendedFor {
@tksmaru
tksmaru / authentication.js
Created November 11, 2015 21:10
javascriptにおける継承の実装サンプル
module.exports = Authentication;
// @Constructor
function Authentication(name) {
this._name = name;
};
Authentication.prototype._login = function(loginId, password) {
throw new Error("not implemented");
@tksmaru
tksmaru / backlogs_printable_cards.rb
Created February 23, 2013 23:46
カードの印刷で日本語が化けるので、代替としてMiguフォントを使用するようにした。 また、ttfフォルダに当該フォントファイルを置けば、ひとまずbacklogsのカードを印刷しても文字化けしない。
fontdir = File.dirname(__FILE__) + '/ttf'
@pdf.font_families.update(
"DejaVuSans" => {
:bold => "#{fontdir}/migu-1p-bold.ttf",
:italic => "#{fontdir}/migu-1p-regular.ttf",
:bold_italic => "#{fontdir}/migu-1p-bold.ttf",
:normal => "#{fontdir}/migu-1p-regular.ttf""
}
)
@pdf.font "DejaVuSans"
@tksmaru
tksmaru / MultiThreadFizzBuzz.java
Created March 6, 2013 13:07
社内勉強会で30分くらいで書いた。いろいろうんこ。
package jp.tksmaru.thread;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class MultiThreadFizzBuzz {
private static final int MAX = 100;
@tksmaru
tksmaru / InterfaceTest.java
Created April 5, 2013 00:37
引数が継承関係にあるオーバーロードメソッドの挙動確認
import java.util.*;
/**
* 引数が継承関係にあるオーバーロードメソッドの実験
*/
public class InterfaceTest {
/** Collection を要求する */
public static <T> void doSomething(Collection<T> collection) {
System.out.println("1");
@tksmaru
tksmaru / StringUtilsTest.groovy
Last active December 15, 2015 21:19
StringUtilsにまんまと騙された件
@Grab(group='commons-lang', module='commons-lang', version='2.6')
import org.apache.commons.lang.StringUtils;
assert ! StringUtils.isAlpha("2"); // false
assert StringUtils.isAlpha("a"); // true
assert ! StringUtils.isAlpha("あ"); // true…だと…?
@tksmaru
tksmaru / InterfaceTest.java
Created April 16, 2013 16:36
適切なインターフェース型が存在しない例のその2
public class InterfaceTest {
public static void main(String[] args) {
// 基底クラスで型を宣言
CoreSysMember member = new Ohta();
//CoreSysMember member = new ItashikiPro();
System.out.println(member.getName());
}
/**