Skip to content

Instantly share code, notes, and snippets.

@josephj
josephj / key-event-with-swf.html
Last active December 14, 2015 10:49
SWF swallows any JavaScript key events while it's focused. This demo illustrates how to make key events always work while SWF exists on page.
<!DOCTYPE html>
<html>
<head>
<title>SWF & JavaScript Key Event</title>
<style>
#focusable-link {
position: absolute;
left: -1000em;
top: -1000em;
}
@josephj
josephj / split_combo_url.js
Last active December 14, 2015 09:08
Splits your combo URL if its length exceeds the max length limitation.
function splitUrl(base, files, separator, maxLength) {
base = base || "/";
files = files || [];
separator = separator || ",";
maxLength = maxLength || 1024;
var items = [],
results = [],
url = base + files.join(separator),
@josephj
josephj / array_merge_recursive_distinct.php
Last active September 10, 2023 07:52
Useful PHP script when you want to merge multiple arrays like Y.merge().
<?php
/**
* Copy from http://www.php.net/manual/en/function.array-merge-recursive.php#92195
*
* array_merge_recursive does indeed merge arrays, but it converts values with duplicate
* keys to arrays rather than overwriting the value in the first array with the duplicate
* value in the second array, as array_merge does. I.e., with array_merge_recursive,
* this happens (documented behavior):
*
* array_merge_recursive(array('key' => 'org value'), array('key' => 'new value'));
@josephj
josephj / css3-display-table.html
Created February 19, 2013 03:59
CSS3 - display:table
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="josephj">
<meta name="created" content="2013-02-19">
<title>CSS3 - display:table</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssreset/reset-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssfonts/fonts-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssbase/base-min.css">
@josephj
josephj / 2013-hehuan-hiking.md
Last active December 13, 2015 20:28
2013 春節清境、合歡山旅遊

2013 春節清境、合歡山旅遊

  • 日期:2013/2/15-16
  • 地圖:http://goo.gl/maps/n6H99
  • 開放路肩行駛:
  • 國 3「竹林」至「關西」北上:89K+800 - 81K+400。
@josephj
josephj / iframe-step.js
Last active December 12, 2015 06:19
YUI Widget Sample
// START WRAPPER: The YUI.add wrapper is added by the build system, when you
// use Shifter to build your component from the raw source in this file
YUI.add("iframe-step", function(Y) {
/* Any frequently used shortcuts, strings and constants */
var Lang = Y.Lang;
/* IframeStep class constructor */
function IframeStep(config) {
IframeStep.superclass.constructor.apply(this, arguments);
@josephj
josephj / iframe-step.html
Last active December 11, 2015 22:28
Using native JavaScript to create an OO-style step control.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="">
<meta name="created" content="2013-01-28">
<title> Prototype</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssreset/reset-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssfonts/fonts-min.css">
<style type="text/css">
@josephj
josephj / demo.html
Last active December 11, 2015 05:38
Image / Text module sample.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Image / Text Module</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssreset/reset-min.css">
<link rel="stylesheet" href="http://yui.yahooapis.com/3.7.2/build/cssfonts/fonts-min.css">
<style>
.mod {
width: 50%; /* Set flexible layout for testing */
@josephj
josephj / mask.scss
Created October 19, 2012 02:50
A pure CSS mask which centralizes content inside. ( http://josephj.com/lab/2012/mask/demo.html )
@import "compass";
/**
* A pure CSS mask which centralizes content inside.
* This technique is compatible with IE7+ and major standard browsers.
*
* Required HTML structure:
*
* <div class="mask">
* <div class="mask-box">
* <div class="mask-inner-box">
mods[“ykpsb”] = function () {
// 利用闭包与外界隔绝
var privateVar,
publicFn;
// 内部自行处理,不会影响其他模块
privateVar = "123";
publicFn = function () {};