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
// Guffa's answer in http://stackoverflow.com/questions/659866/is-there-c-sharp-support-for-an-index-based-sort | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace IndexSortTest { | |
class Program { | |
static void Main(string[] args) { | |
List<int> list = new List<int> {4, 2, 3, 1, 8}; | |
int N = list.Count; |
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
// the Fisher–Yates shuffle algorithm | |
// see http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ShuffleTest { | |
class Program { | |
static void Main(string[] args) { | |
List<int> shuffled = ShuffleRange(0, 10).ToList<int>(); |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from itertools import count, takewhile, islice | |
def primes(): | |
yield 2 | |
primes = [2] | |
for i in count(3, step=2): | |
if all(i % prime != 0 for prime in primes): |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from itertools import count, takewhile, islice | |
def primes(): | |
yield 2 | |
yield 3 | |
primes = [2, 3] | |
for i in count(start=5, step=6): |
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
# -*- cperl -*- | |
# ~/.latexmkrc | |
# setting for pdflatex | |
$pdflatex = 'pdflatex -8bit -etex -halt-on-error -synctex=1 %O %S'; | |
# setting for Japanese | |
$latex = 'platex -synctex=1 -halt-on-error %O %S'; | |
$bibtex = 'pbibtex %O %B'; | |
$makeindex = 'mendex %O -o %D %S'; | |
$dvipdf = 'dvipdfmx %O -o %D %S'; | |
# use bibtex as default |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# convert snippet file for neosnippet into snippet files for yasnippet | |
# by Akihiro Uchida, CC0 dedicated to the public domain | |
# see http://creativecommons.org/publicdomain/zero/1.0/ | |
import argparse | |
import os.path | |
import textwrap | |
YASNIPPET_TEMPLATE = """# -*- mode: snippet -*- |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os.path | |
from matplotlib import get_configdir | |
import pickle | |
fpath = os.path.join(get_configdir(), 'fontList.cache') | |
with open(fpath, 'r') as f: | |
fontmgr = pickle.load(f) | |
for fontentry in fontmgr.ttflist: |
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
#!/usr/bin/env bash | |
# coding: utf-8 | |
# A replication script for ZFS | |
# by Akihiro Uchida, CC0 dedicated to the public domain | |
# see http://creativecommons.org/publicdomain/zero/1.0/ | |
usage="usage: $(basename $0) [-v] src dst" | |
die() { | |
echo "$@" >&2 | |
exit 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
#!/usr/bin/env bash | |
# A ZFS snapshots rotation script | |
# by Akihiro Uchida, CC0 dedicated to the public domain | |
# see http://creativecommons.org/publicdomain/zero/1.0/ | |
usage="usage: $(basename $0) [-v] filesystem generation" | |
die() { | |
echo "$@" >&2 | |
exit 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
import sys | |
import numpy | |
array = numpy.loadtxt("test.npy", converters={0: lambda s: eval(s)}).view(complex).reshape(-1) | |
print array |