Skip to content

Instantly share code, notes, and snippets.

enum Foo {
case north, south, east, west
case foo(Int), bar(Int)
case foo(Int)
case foo = 1
func foo() {
switch self {
case .foo:
case .foo(let x):
foo.sort {
}
foo .sort {
}
foo.sort()
foo .sort()
sort {
}
@taku0
taku0 / AOTSample.java
Created October 6, 2017 12:40
Sample program for AOT for JDK 9
// javac AOTSample.java
// jaotc *.class
// time java AOTSample
// time java -XX:AOTLibrary=./unnamed.so AOTSample
public class AOTSample {
public static class Cons<T> {
private final T value;
private final Cons<T> next;
@taku0
taku0 / A.java
Created November 13, 2016 08:51
class A {
final int x = 1;
public boolean foo() {
return "a2" == ("a" + (x + 1));
}
}
@taku0
taku0 / gaussian_benchmark.c
Last active November 6, 2016 02:19
Box-Muller法による標準正規分布からのサンプリングと、Irwin–Hall分布による近似のベンチマーク
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <time.h>
/* 一様分布に従う疑似乱数値を返す */
static uint64_t uniform1(void);
static uint64_t uniform2(void);
@taku0
taku0 / uniq.js
Created September 19, 2016 13:08
// http://qiita.com/bellbind/items/50954258e262fd7c6bd1
function uniq1(A, i = 0, r = [], h = A[i], l = r.length) {
if (i === A.length) return r;
return uniq1(A, i + 1, l === 0 ? [h] : h === r[l - 1] ? r : [...r, h]);
}
function uniq2(array) {
const result = [];
# coding: utf-8
# たとえば次のような関数を考える。
def foo(array_or_hash)
if array_or_hash.respond_to?(:values)
# Hashっぽい
array_or_hash.values.join(", ")
else
# きっとArray
$ ag patchelf pkgs -l
pkgs/games/adom/default.nix
pkgs/games/nexuiz/default.nix
pkgs/games/ut2004demo/builder.sh
pkgs/games/planetaryannihilation/default.nix
pkgs/games/tremulous/default.nix
pkgs/games/zandronum/default.nix
pkgs/games/zandronum/bin.nix
pkgs/games/xonotic/default.nix
pkgs/games/ue4demos/default.nix
@taku0
taku0 / git.rb
Created July 11, 2016 15:01
Experimental semi-auto updater for firefox-bin package in nixpkgs
$nixpkgs_dir = File.expand_path("~/src/nixpkgs")
def git(*arguments)
options = if arguments.last.kind_of? Hash
options = arguments.pop
else
{}
end
nixpkgs_dir = if options.include?(:nixpkgs_dir)
@taku0
taku0 / Bar.java
Created July 2, 2016 14:07
Exponential type checking
class Tuple<T, R> {
}
class Bar<T> {
public Bar<Tuple<T, T>> d() {
return null;
}
public void bar() {
Bar<Integer> x = d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d().d();