Skip to content

Instantly share code, notes, and snippets.

View s-hiroshi's full-sized avatar

Hiroshi Sawai s-hiroshi

View GitHub Profile
@s-hiroshi
s-hiroshi / observe.js
Created February 29, 2012 04:07
JavaScript > tddjs > for my study of tddjs
/*
Copyright (c) Copyright (c) 2010-2011, Christian Johansen
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@s-hiroshi
s-hiroshi / infotown.center.js
Created March 29, 2012 07:33
jQuery > plugin > layout element to center
/**
*
* layout element to center for targettarget
*
* @param {jQuery} target optional
* @param {String} type optional vertical, horizonal, all
* @return jQuery Object
*/
jQuery.fn.setCenter = function(target, type) {
target = target || $(window);
@s-hiroshi
s-hiroshi / typo.js
Created April 18, 2012 05:40
JavaScript > lib > It displays one character at a time.
<html>
<body>
<p id="foo"></p>
</body>
</html>
@s-hiroshi
s-hiroshi / index.html
Created April 18, 2012 13:59
JavaScript > pattern > cross browser event listener (JavaScriptパターン p194)
<html>
<body>
<p><button id="foo">Click</button></p>
</body>
</html>
@s-hiroshi
s-hiroshi / customtimeout.js
Created April 21, 2012 11:57
JavaScript > pattern > setTimeout
/**
* Custom function can pass arguments(string, number, object, array, function) to a function.
*/
/**
* 参考サイト
* WIZARD-CODE ウィザード・コードのブログ | WIZ-CODE.blog
* http://wiz-code.digick.jp/blog/?p=711
*/
function customTimeout() {
@s-hiroshi
s-hiroshi / mediaquary.html
Created April 23, 2012 11:27
CSS > Media Query template
<html>
<head>
<style>
<link href="smartphone.css" rel="stylesheet" type="text/css" media="only screen and (min-width: 0px) and (max-width: 320px)" />
<link href="tablet.css" rel="stylesheet" type="text/css" media="only screen and (min-width: 321px) and (max-width: 768px)" />
<link href="tablet.css" rel="stylesheet" type="text/css" media="only screen and (min-width: 769px)" />
</head>
<body>
</body>
</tml>
@s-hiroshi
s-hiroshi / mediaquery.css
Created April 23, 2012 12:01
CSS > Media Query2
/**
* <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
**/
#foo {
margin: 0 auto;
min-width: 769px;
max-width: 980px;
}
#bar {
@s-hiroshi
s-hiroshi / index.html
Created May 8, 2012 04:32
jQuery > moodal window (greater than IE 7)
<h1>Modal Window</h1>
<ul style="list-style: none">
<li><a href="images/photo1.jpg" class="modal"><img src="images/photo1_thum.jpg" alt="写真1" /></a></li>
<li><a href="images/photo2.jpg" class="modal"><img src="images/photo2_thum.jpg" alt="写真2" /></a></li>
<li><a href="images/photo3.jpg" class="modal"><img src="images/photo3_thum.jpg" alt="写真3" /></a></li>
</ul>
@s-hiroshi
s-hiroshi / createfile.php
Created May 14, 2012 06:31
PHP > create file
/**
* create file
*/
function createFile($dir, $file) {
$html = <<<HTML
<!DOCTYPE HTML>';
<html lang="en">';
<head>
<meta charset="UTF-8">
<title></title>
@s-hiroshi
s-hiroshi / gist:2692130
Created May 14, 2012 06:18
WordPress > draw calender
/*
* カレンダー出力関数
* @param $id 投稿ID
* @param $y 年 数字4桁
* @param $m 月 数字1~13
* @param $days 日付 配列 添え字[1~31] 値[空, close, holiday]
*/
function drawCalender ($id, $y, $m, $days) {
// $y 年 $m 月
$t = mktime(0, 0, 0, $m, 1, $y); //$y年$m月1日のUNIXTIME