Skip to content

Instantly share code, notes, and snippets.

@picacure
picacure / tiny Promise.js
Last active January 1, 2016 08:58 — forked from unscriptable/tiny Promise.js
异步 Substitute
// (c) copyright unscriptable.com / John Hann
// License MIT
// For more robust promises, see https://github.com/briancavalier/when.js.
function Promise () {
this._thens = [];
}
Promise.prototype = {
@picacure
picacure / hr.css
Last active December 18, 2018 13:40
CSS 奇淫技巧
//
hr{
border-width: 0px;
border-top: 2px dashed #d8d8d8;
color: #d8d8d8;
height: 1px;
}
@picacure
picacure / coin.js
Last active December 22, 2015 06:38
Event
var fireEvent = function (element,event){
var evt = document.createEvent('HTMLEvents');
// initEvent接受3个参数:
// 事件类型,是否冒泡,是否阻止浏览器的默认行为
evt.initEvent(event, true, true);
return !element.dispatchEvent(evt);
};
@picacure
picacure / Itween.cs
Last active December 22, 2015 06:38
缓动
iTween.MoveBy(gameObject,iTween.Hash(
"x" , 2,
"time", 0.2f
));
iTween.MoveTo(gameObject,iTween.Hash(
"x",6,"time",4,
"loopType","pingPong",
"delay",.4,
"easeType","easeInOutQuad"
@picacure
picacure / Uri parse.js
Last active December 20, 2015 14:49
Uri URL
/**
* Created by jiangcheng.wxd on 14-5-28.
*/
(function(window){
var Query = (function (queryString) {
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
@picacure
picacure / requestAnim.js
Last active December 9, 2015 20:48
动画
// Lastly, add in the `requestAnimationFrame` shim, if necessary. Does nothing
// if `requestAnimationFrame` is already on the `window` object.
(function () {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame =
window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
}
@picacure
picacure / gist:3281749
Last active October 8, 2015 04:59
Simple PHP
<?PHP
$json = json_decode(file_get_contents("data.js"));
$callback = $_GET["callback"];
header("Content-type: application/json");
echo $callback.'('.json_encode($json).')';
?>
@picacure
picacure / gist:3205149
Last active October 7, 2015 18:17
Parser
<script type="text/javascript">
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
x=xmlDoc.getElementsByTagName('book')[0];
cloneNode=x.cloneNode(true);
xmlDoc.documentElement.appendChild(cloneNode);
//Output all titles
y=xmlDoc.getElementsByTagName("title");
for (i=0;i<y.length;i++)
{