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
class Foo.<T> { | |
static function callIt(f : () -> T) : void { | |
f(); | |
} | |
} | |
class _Main { | |
static function main(args : string[]) : void { | |
Foo.<void>.callIt(function () {}); | |
} |
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
$ git status | |
# On branch master | |
nothing to commit, working directory clean | |
$ DYLD_INSERT_LIBRARIES=../../unco.dylib DYLD_FORCE_FLAT_NAMESPACE=YES git checkout HEAD^ | |
Note: checking out 'HEAD^'. | |
You are in 'detached HEAD' state. You can look around, make experimental | |
changes and commit them, and you can discard any commits you make in this | |
state without impacting any branches by performing another checkout. |
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
$ git status | |
# On branch master | |
nothing to commit, working directory clean | |
$ unco record --log=/tmp/unco.log git checkout wip | |
Switched to branch 'wip' | |
$ git status | |
# On branch wip | |
nothing to commit, working directory clean |
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
static int _log_exists(const char *dir, long long log_index, int *exists) | |
{ | |
struct stat st; | |
char fnbuf[PATH_MAX]; | |
snprintf(fnbuf, sizeof(fnbuf), "%s/%lld", dir, log_index); | |
if (fstat(path, &st) == 0) { | |
*exists = 1; | |
} else if (errno == ENOENT) { |
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
#include <stdio.h> | |
static int N; | |
static int findN(void) | |
{ | |
int min, max, mid; | |
// index starts from 1; search using Elias encoding (i.e. search at 1,2,4,8,16,... and then perform binary search) | |
for (max = 1; ; max *= 2) { |
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
$ alias git='unco record -- git' <-- set alias | |
$ git status <-- now on 'master' | |
# On branch master | |
nothing to commit, working directory clean | |
$ git checkout wip <-- switch to 'wip' | |
Switched to branch 'wip' | |
$ git status <-- now on 'wip' | |
# On branch wip | |
nothing to commit, working directory clean | |
$ unco history <-- print history |
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
my $fn = do { | |
# some BSD variants (notably OS X) flocks the file handle when calling tempfile() | |
my ($fh, $fn) = tempfile(UNLINK => 1); | |
$fn | |
# setting UNLINK => 1 keeps a hidden reference to the file handle, and thus the file | |
# is not automatically closed when exitting this block | |
}; | |
open my $fh, "<", $fn | |
or die $!; |
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
$ git clone git@github.com:miyagawa/cpanminus.git | |
Cloning into 'cpanminus'... | |
remote: Reusing existing pack: 8570, done. | |
remote: Total 8570 (delta 0), reused 0 (delta 0) | |
Receiving objects: 100% (8570/8570), 3.70 MiB | 96.00 KiB/s, done. | |
Resolving deltas: 100% (3504/3504), done. | |
Checking connectivity... done. | |
$ cd cpanminus/ | |
$ git branch | |
* devel |
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
use strict; | |
use warnings; | |
use Data::Dump qw(dump); | |
sub parse { | |
my $k = shift; | |
my @keys; | |
while (1) { |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <uv.h> | |
static uv_tcp_t sconn, cconn; | |
static uv_connect_t cconn_ctx; | |
static uv_write_t wreq; | |
static uv_buf_t on_alloc(uv_handle_t *handle, size_t suggested_size) |
OlderNewer