Skip to content

Instantly share code, notes, and snippets.

<html>
<body onload="onload()">
<img src="http://please-sleep.cou929.nu/images/twitter-48.png?normal"/>
<iframe src="./test.html?noraml"></iframe>
<script src="./test.js?noraml"></script>
<script>
// img
(new Image()).src = 'http://please-sleep.cou929.nu/images/twitter-48.png?dynamic';
@cou929
cou929 / hash_sample.html
Created July 31, 2013 06:24
以下の html に "hash_sample.html#foobar" というように hash 付きでアクセスする。IE 系は location.hash が取れないがそれ以外のブラウザだととれる。また document.write した script から見えている window.location はもとの 'hash_sample.html' である。
<html>
<body>
<script>
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
var iframe_doc = iframe.contentWindow.document;
iframe_doc.write('<html><body><sc' + 'ript>alert(window.location.hash)</sc' + 'ript></body></html>');
</script>
</body>
</html>
use strict;
use warnings;
my @lines = <>;
print convert( join '', @lines );
sub convert {
my $text = shift;
$text =~ s/\r//g;
@cou929
cou929 / load.html
Last active December 22, 2022 09:01
画像の読み込みにタイムアウトを付けたいけど XHR じゃないと厳しそう
<html>
<body>
<script type="text/javascript">
var blackhole_image_url = 'http://blackhole.webpagetest.org/',
wait_interval = 3000;
// 3秒じゃタイムアウトされない
loadWithImageElement(blackhole_image_url + 'element.png');
// 3秒じゃタイムアウトされない
@cou929
cou929 / colorspace.js
Last active December 12, 2015 08:39
HSV色空間
(function(define) {
define([], function() {
'use strict';
var ColorSpace = function() {};
ColorSpace.prototype.HSVtoRGB = function(h, s, v) {
var r, g, b;
while (h < 0) {
@cou929
cou929 / check_file_update.pl
Created December 27, 2012 08:34
ファイルの更新を監視する nagios plugin
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use File::Find::Rule;
use File::Basename;
my $STATE_OK = 0;
my $STATE_WARNING = 1;
@cou929
cou929 / gist:4334005
Created December 19, 2012 02:57
get start and end ip from range with NetAddr::IP
$ perl -MNetAddr::IP -le "print NetAddr::IP->new('192.168.1.0/24')->range"
192.168.1.0 - 192.168.1.255
@cou929
cou929 / namespace.sample.pl
Created December 18, 2012 07:41
同一ファイルで複数 namespace のテスト
#!/usr/bin/env perl
package TestPack;
use strict;
use warnings;
sub new {
my ($class) = @_;
return bless {}, $class;
}
@cou929
cou929 / gist:4325825
Created December 18, 2012 07:28
to test usage of strptime and strftime of Time::Piece
$ perl -MTime::Piece -le '$t = Time::Piece->strptime("2012-12-10", "%Y-%m-%d"); print $t->strftime("%Y/%m/%d %H:%M:%S")'
2012/12/10 00:00:00
@cou929
cou929 / README.md
Created December 16, 2012 12:08 — forked from Jxck/README.md
libuv サンプル. tcp server & client. クライアントがファイル名を送り, サーバでは足元からファイルを読んでクライアントに返す.

how to compile

$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices server.c -o server
$ gcc -g -Wall -I /path/to/libuv/include /path/to/libuv/uv.a -framework CoreServices client.c -o client