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 net.miuras; | |
import com.sun.istack.internal.NotNull; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.NoSuchElementException; | |
/** | |
* Even if you iterate a CachedIterable object several times, the source Iterable object will be iterated only once. | |
* |
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 net.miuras; | |
import com.sun.istack.internal.NotNull; | |
import java.util.Iterator; | |
import java.util.NoSuchElementException; | |
import java.util.concurrent.LinkedBlockingQueue; | |
/** | |
* When you iterate ProducerConsumerIterable object, the source Iterable object will be iterated in another thread, which you can call a producer thread. | |
*/ |
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
using System; | |
namespace Common | |
{ | |
public static class DateTimeUtil | |
{ | |
/// <summary> | |
/// 二つの時刻値の大きい方を返します。 | |
/// ただし、タイムゾーン設定が異なる場合、Utc>Local>Unspecifiedの優先順位で高い方にそろえます。 | |
/// LocalをUtcにそろえるときは時刻換算が発生します。 |
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
public static <T1,T2> Iterable<Tuple<T1,T2>> zip ( | |
final Iterable<? extends T1> src1, | |
final Iterable<? extends T2> src2) { | |
return new Iterable<Tuple<T1, T2>>() { | |
@Override | |
public Iterator<Tuple<T1, T2>> iterator() { | |
final Iterator<? extends T1> iterator1 = src1.iterator(); | |
final Iterator<? extends T2> iterator2 = src2.iterator(); | |
return new Iterator<Tuple<T1, T2>>() { | |
@Override |
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
module Functional { | |
export class Either<L, R> { | |
constructor(public apply: <TResult>(funcL: (p: L) => TResult, funcR: (p: R) => TResult) => TResult) { } | |
static left<L, R>(obj: L): Either<L, R> { | |
return new Either<L, R>(<TResult>(funcL: (p: L) => TResult, funcR: (p: R) => TResult) => funcL(obj)); | |
} | |
static right<L, R>(obj: R): Either<L, R> { | |
return new Either<L, R>(<TResult>(funcL: (p: L) => TResult, funcR: (p: R) => TResult) => funcR(obj)); |
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
/** | |
* 渡されたアクションを先頭からどれか成功するまで順に実行します。すべて失敗した場合最後の例外をRuntimeExceptionでくるんで投げます。 | |
* Tries to execute given actions until one of them succeeds. Throws RuntimeException if all of them fail. | |
*/ | |
public class Try { | |
public static void these(Runnable... actions) { | |
Throwable lastThrown = null; | |
for (Runnable action: actions) { | |
try { | |
action.run(); |
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
public String toString() { | |
Iterator<E> it = iterator(); | |
if (! it.hasNext()) | |
return "[]"; | |
StringBuilder sb = new StringBuilder(); | |
sb.append('['); | |
for (;;) { | |
E e = it.next(); | |
sb.append(e == this ? "(this Collection)" : e); |
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
public interface IEnvironmentFetcher { | |
DateTime GetTime(); | |
… | |
} |
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
typedef struct{ | |
double x; | |
double y; | |
} vector2D; | |
vector2D nearest(vector2D A, vector2D B, vector2D P) { | |
vector2D a, b; | |
double r; | |
a.x = B.x - A.x; |
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
CREATE UNIQUE INDEX mail_is_unique ON users (mail) | |
WHERE status = 0; |
OlderNewer