「skip」を含む日記 RSS

はてなキーワード: skipとは

2010-06-11

今更語られるFlash真実


Flashを見るか見ないかはユーザーの自由だ

「だーっロゴ回転させてんじゃねーよ!Skipボタンどこだ?!お前らの歌なんか知るかー!もう見ねえよ!」

オンラインのAdobeStore…これって……いつものように大塚商会に頼むか」

Flashを使うかそうでないかもユーザーの自由だ

「あのさーもっとズバーンッときてスパッスパッてイメージにしたいんだよねぇ」

「ColdFusionがクソだ?Flexインポ野郎だ?それがウチの商品なんだよ!」

しかしFlashを選べないというのは単に不自由だ

「なんでこのページ見られないの?」

2009-10-04

グーグルマップ壁紙にしてみる

10/18 改訂

グーグルマップ航空写真をつなげて一枚にするスクリプト

なお、取得した画像著作権グーグル他各社が保持しています。

ご利用は計画的に私的範囲でどうぞご利用ください。

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;
use LWP::UserAgent;
use GD;

my $cmdline = join(" ", $0, @ARGV);
my $usage = "usage: $0 -sx=116423 -sy=51603 -ex=116426 -ey=51605 -dx=4 -dy=3 -z=17 -size=300 -get=30 -dir=cache -output=output.jpg -nodebug";
my ($sx, $sy) = (0, 0);
my ($ex, $ey) = (0, 0);
my ($dx, $dy) = (4, 3);
my $z = 17;
my $size = 300;
my $get = 30;
my $dir = "cache";
my $output = "output.jpg";
my $debug = 0;
GetOptions("sx=i" => \$sx, "sy=i" => \$sy,
	   "ex=i" => \$ex, "ey=i" => \$ey,
	   "dx=i" => \$dx, "dy=i" => \$dy,
	   "z=i" => \$z,
	   "size=i" => \$size, "get=i" => $get,
	   "dir=s" => \$dir, "output=s" => \$output,
	   "debug!" => \$debug) or die "$usage\nDied";
if ($ex == 0) {
    $ex = $sx + $dx;
} else {
    $ex++;
    $dx = $ex - $sx;
}
if ($ey == 0) {
    $ey = $sy + $dy;
} else {
    $ey++;
    $dy = $ey - $sy;
}
$sx>0 and $dx>0 and $sy>0 and $dy>0 and $z>0 and $dir and $output
    or die "$usage\nBad arguments";
$dx*$dy > $size and die "Getting too large.";

$debug and print "debug: mkdir $dir\n";
mkdir $dir;
-d $dir or die "can't make dir $dir: $!";

my $base = sprintf("http://khm%d.google.co.jp/kh/v=46&z=%d", int(rand(4)), $z);
my $ua = LWP::UserAgent->new;
printf "now get %d images...\n", $dx*$dy;
for (my $x=$sx; $x < $ex; $x++) {
    for (my $y=$sy; $y < $ey; $y++) {
	my $file = sprintf("%s/%02dz%06dx%06d.jpg", $dir, $z, $x, $y);
	$debug and print "debug: check of $file\n";
	-s $file and next;
	--$get < 0 and last;
	my $req = HTTP::Request->new(GET=>+"$base&x=$x&y=$y");
	$debug and print "debug: fetch from ".$req->uri."\n";
	my $res = $ua->request($req);
	unless ($res->is_success) {
	    print "fail fetch from $file: ", $res->status_line, "\n";
	    next;
	}
	if (open(my $fh, ">", $file)) {
	    $debug and print "debug: write of $file\n";
	    binmode $fh;
	    print $fh $res->content;
	    close $fh;
	} else {
	    print "fail open in $file: $!\n";
	}
    }
}
$get < 0 and print "reach the getting limit, skip after all.\n";

printf "creating %dX%d image...\n", 256*$dx, 256*$dy;
my $image = new GD::Image(256*$dx, 256*$dy);
for (my $x=$sx; $x < $ex; $x++) {
    for (my $y=$sy; $y < $ey; $y++) {
	my $file = sprintf("%s/%02dz%06dx%06d.jpg", $dir, $z, $x, $y);
	$debug and print "debug: check of $file\n";
	-s $file or next;
	$debug and print "debug: read of $file\n";
	my $part = GD::Image->newFromJpeg($file);
	$debug and print "debug: image copy\n";
	$image->copy($part, 256*($x-$sx), 256*($y-$sy), 0, 0, 256, 256);
    }
}
#$image->string(gdSmallFont, 0, 0, $cmdline, $image->colorAllocate(255, 255, 255));
open(my $fh, ">", $output) or die "fail open $output: $!";
$debug and print "debug: write of $output\n";
binmode $fh;
print $fh $image->jpeg();
close $fh;

例えば秋葉原とか

perl gmwall.pl -sx=116423 -sy=51603 -ex=116427 -ey=51606

駅だけとか

perl gmwall.pl -sx=465701 -sy=206420 -ex=465705 -ey=206423 -z=19

使う数値はfirebugなどで拾ってください。

2009-03-26

ハッシュ関数を調べる

セキュリティ目的ではない。ハッシュテーブルで使うような奴でキャッシュで使いたい。

手軽なほうが良い。軽いほうが良い。推測可能でよい。数十バイトくらいの文字列にしたい。

md5が一番汎用っぽいけど、無駄に重い気がする。crc32は軽そうだしそれなりに汎用っぽいけど、ハッシュ長が短いのがめんどい

ベターはなんだろう。セオリーはなんだろう。

調べた→ http://anond.hatelabo.jp/20090327015620

ベンチ用スクリプト

#!/usr/local/bin/python
from sys import argv, stderr
from time import time
from string import ascii_letters, join
from random import choice
from hashlib import md5
from binascii import crc32
from itertools import izip

time_fmt = '%10s: %5d ms'
shift = int(argv[1]) if len(argv)&gt;1 and argv[1].isdigit() else 2
length = 0x100 << shift
cycle = 0x10000 &gt;&gt; shift
print &gt;&gt; stderr, 'string length: 0x%x, cycle: 0x%x' % (length, cycle)
data = tuple(''.join(choice(ascii_letters) for i in xrange(length)) for j in xrange(cycle))

start = time()
md5hex = tuple(md5(s).hexdigest() for s in data)
print &gt;&gt; stderr, time_fmt % ('md5hex', (time() - start) * 1000)

start = time()
crc32x4 = tuple(''.join('%08x' % abs(crc32(s[i::4])) for i in (0, 1, 2, 3)) for s in data)
print &gt;&gt; stderr, time_fmt % ('crc32x4', (time() - start) * 1000)

start = time()
startend = tuple(s[:16]+s[-16:] for s in data)
print &gt;&gt; stderr, time_fmt % ('headtail', (time() - start) * 1000)

start = time()
skip = tuple(s[::(len(s)/32+1)] for s in data)
print &gt;&gt; stderr, time_fmt % ('skipover', (time() - start) * 1000)

for s in izip(data, md5hex, crc32x4, startend, skip):
    print join(s)

実行結果

% python hashbench.py 0 &gt; hash0.txt
string length: 0x100, cycle: 0x10000
    md5hex:   199 ms
   crc32x4:  1081 ms
  headtail:    30 ms
  skipover:    41 ms
% python hashbench.py 2 &gt; hash1.txt
string length: 0x400, cycle: 0x4000
    md5hex:    83 ms
   crc32x4:   363 ms
  headtail:    10 ms
  skipover:    20 ms
% python hashbench.py 4 &gt; hash2.txt
string length: 0x1000, cycle: 0x1000
    md5hex:    52 ms
   crc32x4:   170 ms
  headtail:     2 ms
  skipover:     5 ms

2009-03-08

XAMPPMySQL文字化け

バージョン2.5

phpとかデータベースをutf8に統一した上で

my.cnfに以下の内容を書き込む。

[client]

default-character-set = utf8

[mysqld]

skip-character-set-client-handshake

default-character-set = utf8

character-set-server = utf8

collation-server = utf8_general_ci

init-connect = SET NAMES utf8

[mysqldump]

default-character-set = utf8

[mysql]

default-character-set = utf8

2009-01-21

ゾウさんが好きです。でもW3Cのほうがもーっと好きです。

http://www.w3.org/

マークアップに困ったときは、ちゃんとマークアップしてそうなサイトを参考にしているんだけど、(なんで今までやらなかったんだろう)初めてW3CのページのHTMLを見た。そしたら、タイトルの下のナビゲーション部分が下のようなマークアップになっていたんだけどさ(改行とインデントは僕がつけた)。

<map title="Introductory Links" id="introLinks" name="introLinks">
  <div class="banner">
    <span class="invisible">
      <a href="#technologies" title="Skip introductory links and the mission statement" class="bannerLink">
        Skip to Technologies
      </a> |
    </span> 
    <a href="/Consortium/activities" accesskey="A" title="W3C Activities" class="bannerLink">
      Activities
    </a> | 
    <a href="/TR/" accesskey="T" title="Technical Reports and Recommendations" class="bannerLink">
      Technical Reports
    </a> | 
    <a href="/Consortium/siteindex" accesskey="S" title="Alphabetical Site Index" class="bannerLink">
      Site Index
    </a> | 
    <a href="/Consortium/new-to-w3c" accesskey="N" title="Help for new visitors" class="bannerLink">
      New Visitors
    </a> | 
    <a href="/Consortium/" accesskey="B" title="About W3C" class="bannerLink">
      About W3C
    </a> | 
    <a href="/Consortium/join" accesskey="J" title="Join W3C" class="bannerLink">
      Join W3C
    </a> | 
    <a href="/Consortium/contact" accesskey="C" title="Contact W3C" class="bannerLink">
      Contact W3C
    </a>
  </div>
</map>

…えっと、普通はっていうか、一般的には、ナビゲーションってul,li要素にしない?map要素ってなにこれ、なんでこんな場所で使われてんの?map要素ってイメージマップに使う要素じゃないの?

http://www.zspc.com/html40/structure/object.html#map

タイトルhttp://pha22.net/hotentry/

2009-01-14

pathtraqの新着サイトランキング

ちょっと前からフィードを購読しているのだけれど気になることがあったのでメモ

http://pathtraq.com/newsite←ここ

時々"LinkBucks.com - Get your share!"というタイトルの新着サイトが流れてくるのだけれど、

クリックするとAdページに飛ばされる。

たとえば、

2009年01月04日には

http://0b7f90f4.realfiles.net/

2009年01月09日には

http://41c2ed5b.viraldatabase.com/

http://966f4bb8.linkbucks.com/

2009年01月12日には

http://aeefbd01.viraldatabase.com/

2009年01月13日には

http://9f771cce.thesegalleries.com/

http://571e8c62.ubucks.net/

http://4939f296.seriousfiles.com/

という感じ。特に09日・13日はこのリンクだけで新着サイトが埋まっていた。

そんで右上にあるSkip Thisをクリックすると今度はhttp://raw-manga.aceboard.fr/の記事ページに飛ぶ。

そこにあるのは違法にアップロードされたであろうコミックの、アップローダへのリンク

これ中の人は把握してるのかなぁ。個人的に邪魔なだけなので消しちゃってほしいのだけれど。

ログイン ユーザー登録
ようこそ ゲスト さん