Skip to content

Instantly share code, notes, and snippets.

View AnhNhan's full-sized avatar

Anh Nhan Nguyen AnhNhan

View GitHub Profile
interface Foo
of Bar | Baz
{}
interface Bar
satisfies Foo
{}
object barInstance satisfies Bar {}
import ceylon.collection {
group
}
import ceylon.test {
assertEquals,
test
}
{String*} splitBy(Boolean(Character) predicate)(String input)
=> input.split(predicate);
/**
Anh Nhan's utilities library
Released under Apache v2.0
Software provided as-is, no warranty
*/
import ceylon.collection {
HashSet,
λ java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
λ javac -version
javac 1.7.0_11
λ ceylon -v
ceylon version 1.1.0 (Ultimate Ship The Second)
@AnhNhan
AnhNhan / Elevator-Saga-001.js
Last active August 29, 2015 14:14
Elevator-Saga-Solution-001.js
{
init: function(elevators, floors) {
//# Elevator[]
var elevs = [];
//# Floor[]
var fls = [];
var equals = function (num)
{
return function (el)
@AnhNhan
AnhNhan / TextPosition.ceylon
Created January 22, 2015 07:27
TextPosition.ceylon
/**
Anh Nhan's utilities library
Released under Apache v2.0
Software provided as-is, no warranty
*/
import ceylon.test {
assertEquals,
// The column struct, with the array
struct Column
{
State[] states;
private bool[State] _uniques;
bool add(ref State state)
{
if (state in _uniques)
{
<?php
function get_in(array $array, array $keys, $default = null)
{
if (!$keys) {
return $array;
}
$current = $array;
foreach ($keys as $key) {
PS C:\Users\AnhNhan\Documents\dev\get-in> php -v
PHP 5.4.11 (cli) (built: Jan 16 2013 20:26:26)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
PS C:\Users\AnhNhan\Documents\dev\get-in> php .\benchmark.php
Time taken (single, not opt): 3.1025559902191
Time taken (single, opt): 2.5755219459534
Time taken (nested, not opt): 4.346479177475
@AnhNhan
AnhNhan / gist:5081935
Last active December 14, 2015 11:49
Some notes
FDEL=4
FILES=`s3cmd ls s3://hcaw/db/ | grep -Po "([a-zA-Z0-9|\/|\:]+\.(.*?))?$" | head -n $FDEL`
for fi in $FILES
do
s3cmd del $FI
done