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
object Main extends App { | |
def possibleSeq(baseSeq: Seq[Option[Boolean]]): Seq[Seq[Boolean]] = | |
baseSeq.foldLeft(Seq(Seq.empty[Boolean])) { (acc, ele) => | |
ele match { | |
case Some(b) => acc.map(_ ++ Seq(b)) | |
case None => acc.flatMap(s => Seq(s ++ Seq(true), s ++ Seq(false))) | |
} | |
} |
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 javax.inject.{Inject, Singleton} | |
import akka.stream.Materializer | |
import play.api.Configuration | |
import play.filters.cors.CORSConfig.Origins.Matching | |
import play.filters.cors.{CORSConfig, CORSFilter} | |
import scala.concurrent.ExecutionContext | |
import scala.util.matching.Regex |
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
#!/bin/bash -eu | |
if [[ $# != 1 ]]; | |
then | |
echo "第一引数にアカウント名を指定してください。" | |
echo "" | |
echo "e.g." | |
echo "$ ./list_policies.sh your_account_name" | |
exit 1 | |
fi |
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 math | |
NUMBER = 100000000 | |
def get_prime_list(limit): | |
limit_sqrt = int(math.ceil(math.sqrt(limit))) | |
prime_bool_list = [False] * 2 + [True] * (limit - 2) | |
for prime_cand in xrange(2,limit_sqrt): | |
if prime_bool_list[prime_cand]: | |
for composite in range(prime_cand ** 2, limit, prime_cand): | |
prime_bool_list[composite] = False |
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
#!/bin/bash | |
set -eu | |
pngFile=$1 | |
headPtr=0 | |
if [ "89504E470D0A1A0A" != $(xxd -ps -u -s $headPtr -l 8 $pngFile) ] | |
then | |
echo "pngファイルではありません" | |
exit 1 | |
fi | |
headPtr=$((headPtr+8)) |
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
#!/bin/bash | |
# this script removes duplicated files | |
# using md5sum. | |
# | |
# $1 : target directory | |
# | |
tmptable=$(mktemp temp.XXXXX) | |
\ls -t ${1%/}/* | while read line | |
do |
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
brew install aalib | |
brew install libcaca | |
brew install mplayer --with-libcaca |
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
sudo git clone git://github.com/yyuu/pyenv.git /usr/local/pyenv | |
sudo git clone git://github.com/yyuu/pyenv-virtualenv.git /usr/local/pyenv/plugins/pyenv-virtualenv |
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
sudo git clone git://github.com/yyuu/pyenv-virtualenv.git /usr/local/pyenv | |
sudo git clone git://github.com/yyuu/pyenv-virtualenv.git /usr/local/pyenv/plugins/pyenv-virtualenv |
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 csv | |
trainReader = csv.reader(open('traindata.csv', 'rb')) | |
nya = [] | |
for row in trainReader: | |
nya.append(row) | |
# train data | |
noarr = filter(lambda row: row[-1] == 'No', nya) | |
yesarr = filter(lambda row: row[-1] == 'Yes', nya) | |
NewerOlder