Skip to content

Instantly share code, notes, and snippets.

View zdying's full-sized avatar

zhang zdying

View GitHub Profile
<!--
English:
This example show how do a simple MVVM code with html+js
You can change the data in design and the object person will be changed, you can too make the change by the console(js) of the property from the object and the visual will be changed.
Portugues:
Esse exemplo mostra como fazer um simples MVVM framework com HTML e JS
Você pode alterar os dados visualmente e o objeto pessoa vai ser alterado e também se você fizer a alteração via console da propriedade o visual será modificado.
-->
<!DOCTYPE html>
<html>
@zdying
zdying / device.js
Created April 3, 2015 15:11
device
(function(win) {
var userAgent = win.navigator.userAgent.toLowerCase ();
win.device = {
'ipod': function(){
return test(/ipod/)
},
'ipad': function(){
return test(/ipad/)
},
#TODO...
var MIN_DISTANCE = 10; // minimum distance to "snap" to a guide
var guides = []; // no guides available ...
var innerOffsetX, innerOffsetY; // we'll use those during drag ...
$( ".draggable" ).draggable({
start: function( event, ui ) {
guides = $.map( $( ".draggable" ).not( this ), computeGuidesForElement );
innerOffsetX = event.originalEvent.offsetX;
innerOffsetY = event.originalEvent.offsetY;
},
@zdying
zdying / context.coffee
Created March 28, 2016 04:00 — forked from watert/context.coffee
Adding context for Express.js req/res cycle
# Adding context for req/res cycle for Express.js.
# With context it would be possible to write more terse code:
#
# app.use ->
# @user = {name: 'Anonymous'}
# @next()
#
# app.get '/', ->
# @res.end "Hello, #{@user.name}"
#
@zdying
zdying / 批量修改文件内容.sh
Created May 11, 2016 07:56
批量修改文件内容
setFile(){
echo "处理文件/目录: $1"
for file in $1
do
if [ -d $file ];then
# echo "$file is dir"
setFile "$file*"
elif [ -f $file ];then
echo "处理文件: $file"
echo "<h1>Error :(</h1>" > $file
@zdying
zdying / flip.html
Created May 11, 2016 10:29
css3 flip
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Flip</title>
<style>
.row{
display: block;
clear: both
}
@zdying
zdying / dragable.html
Last active May 11, 2016 10:53
HTML5 拖放
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Dragable</title>
<style>
ul, li{ padding: 0; margin: 0 }
#source{ width: 140px; overflow: hidden; float:left; margin-left: -10px; }
.item{ width: 60px; height: 60px; list-style: none; line-height: 60px; font-size: 26px;
color: white; text-align: center; float: left; margin: 0 0 10px 10px; cursor: move }
@zdying
zdying / 阶段高点和低点.html
Created July 24, 2016 14:04
阶段高点和低点
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>N</title>
<style media="screen">
#con{
position: relative;
height: 160px;
background: #2C323C;
@zdying
zdying / index.html
Created August 6, 2016 12:18
贝塞尔曲线的可视化操作实现——Photoshop钢笔工具的初级模拟
<!doctype html>
<html>
<head>
<meta charset='UTF-8' />
<title>贝塞尔曲线可视化操作</title>
<style>
*{padding:0;margin:0;}
body{padding:20px;}
</style>
</head>