Skip to content

Instantly share code, notes, and snippets.

View pazworld's full-sized avatar

pazworld pazworld

View GitHub Profile
@pazworld
pazworld / 21lesson.factor
Created June 3, 2014 10:22
「レッスンは何曜日?」をFactorで(横へな21) ref: http://qiita.com/pazworld/items/017cf70768356a43f064
USING: kernel sequences sequences.deep math math.order math.parser
arrays splitting assocs sorting ;
IN: 21lesson
! 希望リストから配属候補を求める
: wish-list>candidate ( wish-list -- candidate )
{ 1 2 3 4 5 } swap [
[ second first over = ] filter
[ first ] map swap drop
] curry map ;
@pazworld
pazworld / 18notfork.factor
Created June 11, 2014 03:53
「フォークじゃない」をFactorで(横へな18) ref: http://qiita.com/pazworld/items/32c057194365b9339d71
USING: arrays generalizations kernel math
math.parser sequences sorting strings ;
IN: 18notfork
SYMBOL: o ! 客を表す記号
SYMBOL: x ! 絶望的に長くかかる客を表す記号
: throughput ( -- seq ) { 2 7 3 5 2 } ; ! 各レジの処理能力
: shortest ( regi -- n ) ! 最も短いレジを探す とは
@pazworld
pazworld / irrpas.dot
Last active August 29, 2015 14:06
「上と左の合計」をErlangで(横へな22) ref: http://qiita.com/pazworld/items/ccc5e9c4d8bda7675a8c
digraph irrpas {
start -> tokens [ label="Data" ];
subgraph cluster_solve {
label="solve";
tokens [ label="string:tokens\n':'で分ける", fontname="IPAexGothic" ];
tokens -> parse_size [ label="SizeStr" ];
tokens -> parse_concat_list [ label="ConcatListStr" ];
parse_size [ label="parse_size\n文字列→サイズ", fontname="IPAexGothic" ];
parse_size -> init_dep_map [ label="Size" ];
parse_size -> get_renum_map [ label="Size" ];
@pazworld
pazworld / irrpas2.erl
Last active August 29, 2015 14:06
「上と左の合計」をErlangで(横へな22) その2 ref: http://qiita.com/pazworld/items/03a9d342025961e6e9ff
-module ( irrpas2 ).
-compile ( export_all ).
solve ( DataString ) ->
[ { Width, Height } | ConcatCells ] = parse_input_string ( DataString ),
TargetCellValueWithMemo = get_value ( Width - 1, Height - 1, ConcatCells, [] ),
get_right_two_digit ( element ( 1, TargetCellValueWithMemo ) ).
parse_input_string ( InputString ) ->
NumberStrings = string:tokens ( lists:delete ( $x, InputString ), ":," ),
#!/bin/sh
# calculate maximum drawdown.
awk '
START {max=0;maxdrawdown=0}
max<$3 {max=$3;print "set max",$1,max}
{drawdown=max-$3}
include Math
def main
puts "6 digits"
check_range((100..999), 1000)
puts "10 digits"
check_range((10000..99999), 100000)
end
@pazworld
pazworld / searchbysubject.js
Created December 15, 2012 01:43
This bookmarklet shows list of messages in inbox of Gmail those subject contain specified string. このブックマークレットはGmailの受信トレイにある、タイトルに指定された文字列を含むメッセージをリストで表示します。 http://d.hatena.ne.jp/paz3/20121010/1349849858
javascript:(function(){var%20s=window.prompt("%E3%82%BF%E3%82%A4%E3%83%88%E3%83%AB%E3%81%AE%E4%B8%80%E9%83%A8%E3%82%92%E5%85%A5%E5%8A%9B%E3%81%97%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84%E3%80%82");if(!s)return;document.getElementById("gbqfq").value="in:inbox%20subject:"+s;document.getElementById("gbqfb").click();})();
@pazworld
pazworld / maybe_monad.js
Created January 13, 2013 12:38
Maybe monad written in JavaScript.
// Maybe monad.
var Maybe = {
Just: function(a) {
this.value = a;
this.bind = function(f) { return f(this.value); };
},
None: function() {
this.bind = function() { return this; };
},
@pazworld
pazworld / diff_two_text.sh
Created March 1, 2013 11:14
Show diff of two input from STDIN.
#!/bin/sh
echo "Input first file, then Ctrl-D"
echo -n "> "
cat >old.txt
echo "Input second file, then Ctrl-D"
echo -n "> "
cat >new.txt
package controllers
import play.api._
import play.api.mvc._
import play.api.db._
import play.api.Play.current
import anorm._
import java.sql._
object Application extends Controller {