Skip to content

Instantly share code, notes, and snippets.

View odiak's full-sized avatar

Kaido Iwamoto odiak

View GitHub Profile
var sum = function () {
var memo = [];
return function (n, a, r) {
if (typeof memo[n] !== "undefined") {
return memo[n];
}
return memo[n] = (n === 1 ? a : a + r * sum(n - 1, a, r));
};
}();
@odiak
odiak / .vimrc
Created May 21, 2011 16:26
my vimrc
set showmatch
set tabstop=5
set number
set autoindent
set nocindent
set shiftwidth=5
set backspace=indent,eol,start
set fileencoding=utf-8
set encoding=utf-8
@odiak
odiak / hoge.c
Created June 13, 2011 07:28
hoge.c
#include <stdio.h>
int main (void) {
int a, n;
scanf("%d", &a);
switch(a) {
case 2 :
n = 28;
break;
case 4 :
#!/bin/bash
file="$HOME/.knct_login"
tim=100
url="http://10.10.10.10/cgi-bin/opengate"
if [ ! -f $file ]; then
:> $file
@odiak
odiak / gist:1091777
Created July 19, 2011 09:01 — forked from namusyaka/gist:1091385
外部リンク自動検出のやつ source:rskull
(function () {
var regex = /^(https?:\/\/(?:[0-9a-z\-]\.?)+(?::\d+)?)(?:\/.*)?$/,
replace = "$1",
baseURL = location.href.replace(regex, replace),
links = document.links,
i, len, href;
for (i = 0, len = links.length; i < len; i ++) {
href = links[i].href;
if (regex.test(href) && href.replace(regex, replace) !== baseURL) {
Function.prototype.applyNew = function (args) {
var that = new Object(), res;
if (typeof args !== "object" || args.constructor !== Array) {
args = [];
}
if (typeof this.prototype === "object") {
that.__proto__ = this.prototype;
}
!function () {
if (typeof jQuery === "undefined") { return; }
var $ = jQuery;
Object.prototype.$ =
Object.prototype.jQuery = function () {
return $(this.valueOf());
};
<?php
function get_abs_url($url, $base_url = '') {
$reg_url = '@^(https?)://([a-z0-9]+(?:\.[-a-z0-9]+)*)(|:\d+)((?:/[^\?]*)?)(|\?.*)$@';
if (preg_match($reg_url, $url, $m)) {
return $url;
}
if (preg_match($reg_url, $base_url, $m)) {
@odiak
odiak / scanf.py
Created December 16, 2011 23:59
scanf.py
#!/usr/bin/env python
# coding: utf-8
# scanf.py - written by odiak
#
# example.
# i, f = scanf('%d%d')
# s = scanf('%s')
import sys
#!/usr/bin/env python