Skip to content

Instantly share code, notes, and snippets.

View pazworld's full-sized avatar

pazworld pazworld

View GitHub Profile
@pazworld
pazworld / showsamesender.js
Last active October 21, 2022 09:19
This bookmarklet shows list of messages in inbox of Gmail which sender is same to the message currently shown.このブックマークレットはGmailで現在表示しているメッセージと同じ送信者から来た受信トレイにあるメッセージをリストで表示します。http://d.hatena.ne.jp/paz3/20120911/1347341170
javascript:(function(){var es=document.getElementsByClassName("gD");if(es.length==0)return;var e=es[0].getAttribute("email");window.location.href='/mail/u/0/#search/in%3Ainbox+from%3A'+e;})();
@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 / monad_law_tests.js
Created January 13, 2013 12:55
Monad law test for my Maybe monad.
// Test monad laws.
// Monad laws are described in http://www.haskell.org/haskellwiki/Monad_Laws
test("return a >>= f should be equivalent to f a", function() {
var f = function(a) { return Maybe.return(a * 3); };
var lhs = Maybe.return(5).bind(f);
var rhs = f(5);
deepEqual(lhs, rhs, "equivalent");
});
@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 {
@pazworld
pazworld / yy.erl
Last active December 18, 2015 01:38
%% -*- coding: utf-8 -*-
-module(yy).
-export([start/0]).
monsters() -> ["焼きたてパン", "強いシャチホコ", "もんじゃ焼き一年生",
"怪人ホタテ男", "ニセ勇者", "逃げ足の早いアレ", "睡魔", "煩悩",
"愛らしい子犬の中の人", "恋するスズメバチ", "勇敢なクマンバチ",
"信じられない物", "勇者の師匠", "浮遊する鎧", "怪盗ドボン", "闇の招き猫",
"誘惑のカスタードクリーム", "しょっぱすぎる籠手", "カレー味の兜",
@pazworld
pazworld / ifb.erl
Last active December 18, 2015 04:49
-module(ifb).
-export([sample/0, find/1]).
sample() ->
write_ifb([fizz]),
write_ifb([buzz]),
write_ifb([fizz, buzz]),
write_ifb([buzz, fizz]),
write_ifb([fizz, buzz, fizz]),
write_ifb([fizz, fizz]),
@pazworld
pazworld / ba.erl
Last active December 18, 2015 15:28
-module(ba).
-export([tests/0, test/2, amida/1]).
tests() ->
test("d6-7b-e1-9e", "740631825"), % #0
test("6f-dd-ff-ff", "230685147"). % #41
test(Data, Expected) ->
io:fwrite("~s -> ~s, ~w~n", [Data, Expected, amida(Data) =:= Expected]).
@pazworld
pazworld / eq.erl
Created June 28, 2013 10:17
「エイト・クイーン問題」をErlangで ref: http://qiita.com/pazworld/items/2a50f208ca2e5c1b4098
% solve 8-queens problem.
-module(eq).
-compile(export_all).
solve() ->
register(counter, spawn(fun() -> counter(0) end)),
solve(cols(), []),
counter ! show.