Skip to content

Instantly share code, notes, and snippets.

View yoko's full-sized avatar
🍐
I like pear

yksk yoko

🍐
I like pear
View GitHub Profile
@yoko
yoko / gist:54510
Created January 29, 2009 11:38
Parses date string when format like "2009-01-01T00:00:00Z".
function parseDate(str) {
var d = str.split(/\D/);
--d[1];
var time = Date.UTC.apply(null, d);
return new Date(time);
}
@yoko
yoko / gmsetvalueandgmgetvalueongreasekitsample.user.js
Created February 2, 2009 12:49
クッキーを使った疑似GM_setValue/getValue
// ==UserScript==
// @name GM_setValue and GM_getValue on GreaseKit Sample
// @namespace http://codefairy.org/ns/userscripts
// @include *
// @version 0.1
// @license MIT License
// ==/UserScript==
new function() {
registerGM_value('Foo', 1);
(function($) {
$.override = function(target, copy) {
$.each(copy, function f(k, v) {
if (v === null)
delete target[k];
else if (typeof v == 'object') {
target[k] = target[k] || ($.isArray(v) ? [] : {});
var _target = target;
var _copy = copy;
target = target[k];
str = 'abcdefghijk';
re_1 = /.*(a).*/; // 1
re_2 = /.*(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k).*/; // 11
alert(str.replace(re_1, '$1111')); // $1 + "111"
alert(str.replace(re_2, '$1111')); // $11 + "11"
alert(str.replace(re_2, '$1'+'111')); // TRAP! $11 + "11"
alert(str.replace(re_2, function() {
return arguments[1]+'111'; // $1 + "111"
(function($) {
$.phparam = function(o) {
var ret = {};
var root, tree = [];
$.each(o, function deep(k, v) {
if (!root) root = k;
else tree.push(k);
if (typeof v == 'object')
$.each(v, deep);
@yoko
yoko / jquery.replaceimage.js
Created February 27, 2009 09:55
yet another jQIR.
(function($) {
var options = {
path: '/img'
};
$.replaceImageSetup = function(o) {
options = o;
};
$.fn.replaceImage = function(ext) {
(function($) {
$.fn.sameHeight = function() {
var h = 0;
return this
.each(function() {
h = Math.max($(this).height(), h);
})
.height(h);
};
})(jQuery);
parse = function(hash) {
var ret = {};
var hash = /#(.+)/.exec(hash || location.href); // Can't use the location.hash, Fx decodes automatically.
if (hash)
hash = h[1];
else
return ret;
$.each(queries.split('&'), function() {
if (!this) return;
$.fn.backgroundImage = function(src) {
var bg = $.browser.msie6 ?
{ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+src+'")' } :
{ backgroundImage: 'url('+src+')' };
return this.each(function() {
$(this).css(bg);
});
};
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>jquery.inputprompt.js</title>
<link rel="stylesheet" type="text/css" href="http://view.jquery.com/trunk/qunit/testsuite.css"/>
<style type="text/css">
#container {
position: absolute;
top: 0;