Skip to content

Instantly share code, notes, and snippets.

@sakunyo
sakunyo / gist:1180199
Created August 30, 2011 04:42
css fontsize14px
.fzSS { font-size: 71.4%;}/* 10px */
.fzS { font-size: 85.7%;}/* 12px */
.fzM { font-size: 100%;} /* 14px */
.fzL { font-size: 114.2%;}/* 16px */
.fzLL { font-size: 128.5%;}/* 18px */
.fzLLL { font-size: 142.8%;}/* 20px */
sup { font-size: 85.7%; vertical-align: top;}
sub { font-size: 85.7%; vertical-align: baseline;}
@sakunyo
sakunyo / log.js
Created August 16, 2011 04:16
log
function PrintLog(p){
var d = document,
df = d.createDocumentFragment(),
p = p || 'result',
r = d.getElementById(p);
return function(s){
df.appendChild(d.createTextNode(s));
df.appendChild(d.createElement('br'));
r.appendChild(df);
@sakunyo
sakunyo / gist:1128975
Created August 6, 2011 03:25
css reset module
/* !Reset Module ------------------------------------------------------------ */
.reset div, .reset dl, .reset dt, .reset dd, .reset ul, .reset ol, .reset li, .reset h1, .reset h2, .reset h3, .reset h4, .reset h5, .reset h6,
.reset pre, .reset form, .reset fieldset, .reset p, .reset blockquote, .reset th, .reset td
{ margin: 0; padding: 0;}
.reset input, .reset textarea
{ margin: 0; font-size: 100%;}
.reset table
{ border-collapse: collapse; border-spacing: 0; font-size: 100%;}
.reset fieldset, .reset img, .reset abbr, .reset acronym
{ border: 0;}
@sakunyo
sakunyo / gist:1121362
Created August 2, 2011 22:10
js image over
(function(){
var suffix = { normal : '_no.', over : '_on.'}
$('a.over, img.over, input.over').each(function(){
var a,
img,
el = $(this).get(0),
el_name = el.nodeName.toLowerCase();
src_no,
src_on,
cache;
@sakunyo
sakunyo / gist:1105770
Created July 26, 2011 02:01
js image onload print
(function(){
var loc = document.location.search,
t = new Date(),
img = new Image(),
src = '';
if(loc.indexOf('page=hoge') > -1){
src = 'images/hoge/print.jpg'+'?'+t.getTime();
}else if(loc.indexOf('page=fuga') > -1){
@sakunyo
sakunyo / gist:1096201
Created July 20, 2011 23:49
js Fisher-Yates shuffle
// ランダム並び替えの方法が間違ってたのでどれほど間違ってたのかを可視化してみた - さらさら宇宙忍法帖
// http://d.hatena.ne.jp/gotin/20071211/shuffle
function shuffle_fy(array){
var n = array.length;
while (--n) {
var k = Math.floor(Math.random() * n); // 0 <= k <= n (!)
var temp = array[n];
array[n] = array[k];
@sakunyo
sakunyo / gist:1096093
Created July 20, 2011 22:29
_php_random_image
<?php
$images = array(
"src" => array( "./test1.gif" , "./test2.gif", "./test3.jpg" ),
"alt" => array( "test1" , "test2" , "test3" )
);
function return_rand_index($arr){
if( is_array($arr) ){
// array
@sakunyo
sakunyo / gist:1088856
Created July 18, 2011 08:12
_js_a_current
(function(){
$('#archive a').each(function(i){
var t = $(this);
if(location.href.indexOf(t.attr('href')) > -1){
t.addClass('current');
}
});
}());
@sakunyo
sakunyo / gist:1003656
Created June 2, 2011 00:17
_js_fxPrint
/* !fxPrint ----------------------------------------------------------------- */
(function(){
setCSS = function(){
elem = document.createElement('link');
elem.setAttribute('rel','stylesheet');
elem.setAttribute('type','text/css');
elem.setAttribute('media','print');
elem.setAttribute('href','common/css/fx_print.css');
document.getElementsByTagName('head')[0].appendChild(elem);