Skip to content

Instantly share code, notes, and snippets.

View fukata's full-sized avatar

fukata fukata

View GitHub Profile
@fukata
fukata / jsunit_util.js
Created September 12, 2011 11:02
jsunit utility
function base_url() {
var url = window.location.href;
var idx = url.lastIndexOf('/');
if (idx > 0) {
url = url.substr(0, idx);
} else {
url = "";
}
return url;
}
@fukata
fukata / post_file_and_data.pl
Created September 28, 2011 02:18
Post file and data use LWP::UserAgent.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Encode;
use HTTP::Request::Common;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
@fukata
fukata / .xmodmap
Created September 28, 2011 04:44
Super_R is mapped Control_R for Thinkpad Travel Keyboard on Ubuntu
remove Control = Control_R
keysym Control_R = Super_R
add Control = Control_R
@fukata
fukata / weight.js
Created October 22, 2011 17:29
Weight Chart at Google Calendar
/**
* Return calendar for weight.
* @return Calendar
*/
function getWeightCal() {
var id = 'YOUR GOOGLE CALENDAR ID';
var cal = CalendarApp.getOwnedCalendarById(id);
return cal;
}
@fukata
fukata / ci_2.0.3_and_2.1.0.diff
Created November 15, 2011 00:09
CodeIgniter 2.0.3 and 2.1.0 diff
diff -ru CodeIgniter_2.0.3//application/config/database.php CodeIgniter_2.1.0//application/config/database.php
--- CodeIgniter_2.0.3//application/config/database.php 2011-08-20 20:59:14.000000000 +0900
+++ CodeIgniter_2.1.0//application/config/database.php 2011-11-01 01:15:36.000000000 +0900
@@ -27,7 +27,8 @@
| ['char_set'] The character set used in communicating with the database
| ['dbcollat'] The character collation used in communicating with the database
| NOTE: For MySQL and MySQLi databases, this setting is only used
-| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7.
+| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
+| (and in table creation queries made with DB Forge).
@fukata
fukata / tag-date
Created January 10, 2012 02:53
sorted commiter date git tags.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use autodie;
sub validate_show_lines {
my ( $show ) = @_;
return @$show[0] =~ /^tag .*$/;
}
@fukata
fukata / vimplus
Created January 12, 2012 17:39
vimplus
#!/bin/bash
VIM=/usr/bin/vim
FILE=${1%:*}
LINE=${1#*:}
if [[ "$LINE" =~ ^[0-9]+$ ]]
then
$VIM +"$LINE" "$FILE"
else
@fukata
fukata / put_text_sample.c
Created February 7, 2012 00:54
put_text_sample
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <time.h>
// http://opencv.jp/sample/text.html
// gcc put_text_sample.c -o put_text_sample `pkg-config --libs --cflags opencv` && ./put_text_sample
int
main (int argc, char **argv)
{
@fukata
fukata / addhost.sh
Created February 24, 2012 09:32
Add virtualhost setting.
#! /bin/bash
###################################################################
#
# 当スクリプトでは、以下のことを行う。
#
# 1./etc/apache2/site-available, /etc/apache2/site-enabledへの
# VirtualHostの設定を記述したファイルを設置
# 2./var/log/apache2に指定したドメインのディレクトリを作成
# 3./etc/hostsに指定したドメインを追加
#
@fukata
fukata / file.m
Created March 6, 2012 02:14
iOS file informations.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dir = [paths objectAtIndex:0];
NSLog(@"dir=%@", dir);
NSString *filePath = [dir stringByAppendingPathComponent:@"hoge.flv"];
NSLog(@"filePath=%@", filePath);
NSFileManager *fm = [NSFileManager defaultManager];
BOOL exists = [fm fileExistsAtPath:filePath isDirectory:NO];
BOOL writable = [fm isWritableFileAtPath:filePath];
BOOL readable = [fm isReadableFileAtPath:filePath];