Skip to content

Instantly share code, notes, and snippets.

View holyzfy's full-sized avatar

倉優小子 holyzfy

  • China
  • Beijing
View GitHub Profile
var promise = require("./promise");
promise.execute(function(callback){
asyncOperation(callback);
}).then(function(result){
console.log("on succ: ", result);
}, function(err) {
console.log("on fail: ", err);
});
@holyzfy
holyzfy / escape.c
Last active December 28, 2015 23:19
XBee api2转义特殊字符
#include <stdio.h>
#include <stdlib.h>
int escape(int[], int, int**);
int unescape(int[], int, int**);
int main()
{
//test: 转义
int data[] = {0x7E, 0x00, 0x02, 0x23, 0x11, 0xCB};
@holyzfy
holyzfy / hover.html
Last active December 30, 2015 11:19
模拟jquery的hover事件效果
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>hover</title>
<style>
.btn {
width: 200px;
background-color: #080;
text-align: center;
@holyzfy
holyzfy / jquery_placeholder.html
Created January 22, 2014 09:17
跨浏览器的html5 placeholder属性解决方案
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>placeholder</title>
<style>
.placehoder_wrap {position: relative;}
.placehoder_wrap label {display: none; position: absolute; left: 3px; top: 1px; color: #ccc; font-size: 12px; padding: 3px; line-height: 20px; white-space: nowrap; cursor: text;}
.field {width: 200px; border: 1px solid #000; height: 20px; padding: 3px; font-size: 12px;}
textarea.field {width: 300px; height: 200px;}
@holyzfy
holyzfy / this_script.html
Created January 27, 2014 06:55
取得html页面里当前script标签节点
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>取得html页面里当前script标签节点</title>
</head>
<body>
<script id="test">
var scripts = document.getElementsByTagName("script");
@holyzfy
holyzfy / ie6_abs.html
Last active January 4, 2016 18:29
解决IE6中absolute定位的问题
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
.wrap { position: relative; width: 400px; height: 300px; border: 1px solid #000;}
.content {float: left; width: 100%; height: 300px; background-color: #ccc;}
.abs {position: absolute; left: 50px; top: 50px; padding: 5px 8px; background-color: #080; color: #fff; font-size: 14px;}
</style>
</head>
@holyzfy
holyzfy / pre.html
Created February 21, 2014 07:56
保留html源码里的文本排版格式
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Document</title>
<style>
.content {
width: 500px;
margin: 0 auto;
white-space: pre-wrap;
@holyzfy
holyzfy / render.js
Last active August 29, 2015 13:56
模板引擎
/**
* 模板引擎
*
* @param {String} template 模板,占位符默认是{}
* @param {Object} data 数据
* @param {RegExp} regexp 用正则自定义占位符
* return {String}
*/
function render(template, data, regexp) {
if (!(Object.prototype.toString.call(data) === "[object Array]")) {
@holyzfy
holyzfy / myTouch.js
Last active August 29, 2015 14:13
touch handle for mobile
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, maximum-scale=1" />
<title>test touch</title>
<script src="http://img1.cache.netease.com/f2e/libs/zepto.js"></script>
<!-- <script src="zepto.js"></script> -->
<style>
.box {
.transition(@val) {
-webkit-transition: @val;
-moz-transition: @val;
-ms-transition: @val;
-o-transition: @val;
transition: @val;
}
.transform(@val) {
-webkit-transform: @val;
-moz-transform: @val;