Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / test_cat2.sh
Created January 10, 2011 04:57
cat2.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
static void die(const char *s);
static void do_cat_from_stdin(void);
@syohex
syohex / pdic2sdic.pl
Created January 16, 2011 01:48
pdic2sdic.pl
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use utf8;
use Encode;
my $last_word = '';
while (my $line = <STDIN>) {
@syohex
syohex / man.pl
Created January 22, 2011 13:36
各種 BSDの manpagesを調べる
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use Config::Pit;
use File::Which qw(which);
use Getopt::Long;
use URI;
@syohex
syohex / sample.sh
Created January 30, 2011 08:11
Perlで指定したファイルをメールで送信する
#!/bin/sh
SEND_FILE=$1
if [ "$SEND_FILE" = "" ]
then
echo "Usage $0 filename"
exit 1
fi
SUBJECT="`date +"%Y%m%d"` $SEND_FILE"
@syohex
syohex / sary.patch
Created February 16, 2011 13:34
saryに表示件数を指定できるオプションを追加
diff --git a/src/sary.c b/src/sary.c
index 22f997d..874359f 100644
--- a/src/sary.c
+++ b/src/sary.c
@@ -112,6 +112,9 @@ static gchar* start_tag = NULL;
static gchar* end_tag = NULL;
static gchar* array_name = NULL;
+#define SEARCH_INFINITE -1
+static SaryInt entry_num = 1000; /* default is 1000 entry */
@syohex
syohex / keysnail_goto_page.js
Created March 31, 2011 15:30
ページの移動
function dmmPage (location, pageNum) {
var nextLocation;
if (location.indexOf("page=") != -1) {
var page = location.match(/page=(\d+)/)[1];
var nextPage = "page=" + (parseInt(page) + pageNum);
nextLocation = location.replace(/page=(\d+)/, nextPage);
} else if (location.indexOf("list") != -1){
if (pageNum < 0) {
return false;
}
@syohex
syohex / url_title.pl
Created April 11, 2011 14:51
短縮URLにタイトルを添えて出力する。
#!/usr/bin/env perl
package App::UrlTitle;
use Mouse;
# reference http://code.google.com/intl/ja/apis/urlshortener/
use LWP::UserAgent;
has ua => (
is => 'rw',
@syohex
syohex / url_title.pl
Created April 16, 2011 00:21
URLのタイトルと短縮URLの取得
#!/usr/bin/env perl
package App::UrlTitle;
use Mouse;
# reference http://code.google.com/intl/ja/apis/urlshortener/
use LWP::UserAgent;
has ua => (
is => 'rw',
@syohex
syohex / print.pl
Created April 23, 2011 05:19
PSプリンタで印刷するためのユーティリティ
#!/usr/bin/env perl
package App::PSPrinter;
use strict;
use warnings;
use Getopt::Long;
use Carp qw(croak carp);
use utf8;
use File::Basename;
@syohex
syohex / git_add_not_space.pl
Created April 25, 2011 15:08
行末のスペースの削除以外の修正を git addする
#!/usr/bin/env perl
use strict;
use warnings;
use File::Which ();
use File::Copy ();
my $GIT = File::Which::which('git');
die "Error: can't find 'git' command\n" unless defined $GIT;