Skip to content

Instantly share code, notes, and snippets.

import qualified System.Time as T
type Year = Int
type Month = Int
type Day = Int
-- Ex. $> h 2013 5 21
-- $> Tuesday
h :: Year -> Month -> Day -> T.Day
h year 1 day = h year 13 day
@nida-001
nida-001 / gist:5733885
Created June 8, 2013 03:25
「最強最速アルゴリズマー」のキウイジュースの問題をGoで写経してみた
package main
import (
"fmt"
)
func main() {
capacities := []int{20, 20}
bottles := []int{5,8}
fromId := []int{0}
@nida-001
nida-001 / gist:5743719
Created June 9, 2013 14:19
みんなが楽しいパーティー
package main
import (
"math"
)
func main() {
first := []string {"f", "g", "s", "f"}
second := []string {"h", "f", "f", "b"}
println(bestInvitation(first, second))
@nida-001
nida-001 / gist:5743811
Created June 9, 2013 14:50
「暗号文」
package main
import (
"fmt"
"sort"
)
func main() {
numbers := []int{1, 2, 3}
fmt.Printf("%v\n", encrypt(numbers))
import java.util.concurrent.ConcurrentHashMap;
public class ConcurrentHashMultiMap<K, V> {
private final ConcurrentHashMap<K, ConcurrentHashMap<V, Boolean>> map = new ConcurrentHashMap<>();
public void put(K key, V value) {
map.putIfAbsent(key, new ConcurrentHashMap<V, Boolean>());
map.get(key).put(value, true);
}
}
@nida-001
nida-001 / gist:6609391
Created September 18, 2013 13:47
並列奇偶転置ソートを試験的に作ってみた
package oddeven;
import java.util.Arrays;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ConcurrentOddEvenSort {
public static void main(String[] args) throws InterruptedException, ExecutionException {
@nida-001
nida-001 / gist:6609842
Created September 18, 2013 14:20
CAS命令使用版並列奇偶転置ソート
package oddeven;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ConcurrentOddEvenSort {
public static void main(String[] args) throws InterruptedException, ExecutionException {
@nida-001
nida-001 / index.html
Created July 1, 2017 12:57
AMP loginを試そうとしたときの残骸
<!doctype html>
<html amp>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<!--
Additionally used AMP components must be imported in the header.
-->
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
@nida-001
nida-001 / marshalljson.php
Created July 4, 2017 11:25
標準入力のJSONをDynamoDB JSONにMarshallする
<?php
require 'vendor/autoload.php';
use Aws\DynamoDb\Marshaler;
$json = "";
while ( ! feof(STDIN) ) {
$line = trim(fgets(STDIN));
$json .= $line;
}