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 / utils.js
Created June 15, 2012 01:40
jQuery > utility for web design
jQuery(function ($) {
// name space
function LightUtils(options) {
var prop;
for (prop in this) {
if (LightUtils.prototype.hasOwnProperty(prop)) {
var res = this[prop]();
}
}
}
@s-hiroshi
s-hiroshi / index.html
Created June 24, 2012 12:31
JavaScript > Smartphone
<!-- たにぐち まこと 「iPhone+Android スマートフォンサイト制作入門」ASCII -->
<script>
if (((navigator.userAgent.indexOf('iphone') > 0 && navigator.userAgent.indexOf('iPad') == -1) || navigator.userAgent.indexOf('iPad') > 0 || navigator.userAgent.indexOf('Android') > 0) {
document.write('<link ref="stylesheet" href="phone.css">');
}
</script>
@s-hiroshi
s-hiroshi / index.html
Created June 24, 2012 12:35
PHP > file upload
<?php
if (is_uploaded_file($_FILES["upfile"]["tmp_name"])) {
// echo $_FILES["upfile"]["name"] . "をアップロードしました。";
// print('<img src="' . $_FILES["upfile"]["tmp_name"] . '">');
echo $_FILES["upfile"]["tmp_name"];
} else {
// echo "ファイルが選択されていません。";
}
?>
<form action="index.php" method="post" enctype="multipart/form-data">
@s-hiroshi
s-hiroshi / ifelse.php
Created June 29, 2012 01:53
WordPress > 条件分岐
<?php if (is_page('foo')) : ?>
<p>foo</p>
<?php elseif (is_page('bar')) : ?>
<p>bar</p>
<?php else : ?>
<p>baz</p>
<? endif; ?>
@s-hiroshi
s-hiroshi / functions.php
Created June 29, 2012 06:54
WordPress > shortcode > bloginfo
<?php
/**
* 入力エディタでbloginfoを取得する。
* @param arg bloginfoの引数
* url ブログのURL
* template_directory テンプレートディレクトリのパス
* stylesheet_directory テーマディレクトリのパス
* デフォルトではblogのURLを返す
*/
function bloginfo_func($atts) {
@s-hiroshi
s-hiroshi / gist:3016372
Created June 29, 2012 06:57
WordPress > shortcode > br
<?php
/**
* 属性numに指定した数の改行をマークアップ。
* @attribute num 改行の数
* 使い方[bar num="3"] 3回改行
*/
function br_func($atts) {
extract(shortcode_atts(array(
'num' => '1'
), $atts));
@s-hiroshi
s-hiroshi / functions.php
Created June 29, 2012 07:01
WordPress > shortcode > img
<?php
/**
* テンプレートディレクトリの画像を利用するショートコード。
* @attribute src テンプレートディレクトリ以降の画像パス。先頭に/を含める
* @attribute alt 代替文字
* @attribute id id名
* @attribute class クラス名
* @attribute width 幅 pxなし
* @attribute height 高さ pxなし
* @attribute type tagならimgタグを返す。 pathならパスを返す。
@s-hiroshi
s-hiroshi / functions.php
Created June 29, 2012 07:30
wordPress > shortcode > heading
<?php
/**
* h1-h6に属性を指定してマークアップする
* @attribute id id名
* @attribute class クラス名
* 属性がない場合は下記のHTMLコードを返す
* <img src="%TEMPLATE_DIRECTORY%/screenshot.png" alt="*" />
* %TEMPLATE_DIRECTORY%はbloginfo('stylesheet_directory')
* 使い方[h1 id="foo" class="bar"]Example[/h1]
*/
@s-hiroshi
s-hiroshi / style.css
Created June 30, 2012 05:04
CSS > general class
/* -------------------------------------------------------------------
general class
------------------------------------------------------------------- */
.text-red {
color: #b74040;
}
.text-center {
text-align: center;
}
.text-right {
@s-hiroshi
s-hiroshi / functions.php
Created July 4, 2012 04:03
WordPress > shortcode > pagetop
<?php
/**
* 「このページの上へ」をマークアップするショートコード。
* @attribute classname div要素のクラス名 省略 pagetop
* @attribute target アンカー名 省略 wrapper
* @attribute text リンクの文字列 このページの上へ。
* 属性がない場合は下記のHTMLコードを返す。
* <div class="pagetop"><a href="#wrapper">このページの上へ</a></div>
* 使い方[pagetop]
*/