Skip to content

Instantly share code, notes, and snippets.

View JacksonTian's full-sized avatar
🚗
Working on Darabonba.

Jackson Tian JacksonTian

🚗
Working on Darabonba.
View GitHub Profile
@JacksonTian
JacksonTian / test.html
Created May 9, 2011 02:34
$.ready issue when dynamic script element insert.
<script>
console.log(document.readyState);
document.onreadystatechange = function () {
console.log(document.readyState);
};
window.onload = function () {
console.log("onload: " + document.readyState);
};
document.addEventListener('DOMContentLoaded', function () {
console.log("domready!");
@JacksonTian
JacksonTian / sleepsortjs.txt
Created June 21, 2011 06:03
Sleep Sort JavaScript版本的简单实现的改进
某个同学的原始版本是这样的。
var arr = new Array(25,35,4,2,8,1,5,3,9,15);
for(i = 0 ; i < arr.length ; i++){
eval("setTimeout(function(){document.write(arr["+i+"] + ' ');},arr["+i+"]);");
}
以下是改进版:
var arr = [25,35,4,2,8,1,5,3,9,15];
var len = arr.length, sorted = [];
for(var i = 0; i < len; i++){
@JacksonTian
JacksonTian / sourcecode.js
Created June 21, 2011 07:29
得到像Firebug的DOM一样的源代码
javascript:(function() {var s=document.documentElement.outerHTML;var w=window.open('xx','');w.document.write(s.replace(/</g, "&lt;").replace(/>/g, "&gt;"));w.focus();}());
@JacksonTian
JacksonTian / event.js
Created July 15, 2011 11:12
转换为事件机
// EventProxy https://github.com/JacksonTian/eventproxy/blob/master/eventproxy.js
/**
* 显示指定用户 profile 页面
*
* 获取关注和被关注的数据
* 获取此用户最近的活动数据
* - 活动数据里面包含各种数据的聚合
* 判断当前登录的用户与指定用户是否已经相互关注
*
*/
@JacksonTian
JacksonTian / farawayjqueryplugin.html
Created August 12, 2011 02:47
组件形式的。珍爱生命,远离jQuery插件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test slider v3</title>
<style>
body {
font-family: Georgia, serif;
}
#slider1, #slider2 {
@JacksonTian
JacksonTian / Image2DataUri.js
Created August 27, 2011 08:43
将图片文件转换为DataUri/Use Nodejs convert image to DataUri.
var fs = require("fs");
var filePath = "../assets/images_out/action_pressed.png";
fs.readFile(filePath, function (err, buffer) {
if (err) {
console.log(err);
} else {
var prefix = 'data:image/png;base64,';
var datauri = prefix + buffer.toString('base64');
fs.writeFile(filePath + ".txt", datauri, function (err) {
if (err) throw err;
@JacksonTian
JacksonTian / chrometab.css
Created August 29, 2011 08:33
Chrome tab
.tab-panel .tabs li:nth-child(5n+1) {
z-index: 10;
}
.tab-panel .tabs li:nth-child(5n+2) {
z-index: 9;
}
.tab-panel .tabs li:nth-child(5n+3) {
z-index: 8;
}
.tab-panel .tabs li:nth-child(5n+4) {
@JacksonTian
JacksonTian / results.txt
Created September 8, 2011 04:00
各种移动设备的viewport取值
Devices landscape(w/h) portrait(w/h)
HTC g10 533/260 320/473
ipad1 1024/690 768/946
ipad2 1024/690 768/946
Samsung9100 533/237 320/450
Samsung9000 533/239 320/452
LePhone 533/250 320/463
ipod(4.2.1) 480/208 320/356
//以下数据来自支付宝 颂赞
MOROTOLA ME722 320/488 569/239
@JacksonTian
JacksonTian / placeholder.js
Created September 15, 2011 09:54
Placeholder
Usage:
b.plug(f.PlaceholderPlugin);
@JacksonTian
JacksonTian / geotest.html
Created September 24, 2011 15:01
GEO research.
<!DOCTYPE html>
<html lang="fr-FR">
<head>
<meta charset="utf-8" />
<title>GEO</title>
</head>
<body id="index">
<script>
navigator.geolocation.getCurrentPosition(function (position) {
console.log(JSON.stringify(position));