Skip to content

Instantly share code, notes, and snippets.

View zdying's full-sized avatar

zhang zdying

View GitHub Profile
@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 / 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 / 批量修改文件内容.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 / 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}"
#
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;
},
#TODO...
@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/)
},
<!--
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 / pathAnimate.swift
Created December 1, 2014 05:26
Path Animate
//
// ViewController.swift
// test
//
// Created by 张代应 on 14/11/28.
// Copyright (c) 2014年 imf2e. All rights reserved.
//
import UIKit
//import CoreText
@zdying
zdying / 两拦布局右侧宽度固定-左侧自适应.html
Created October 15, 2014 02:00
两拦布局右侧宽度固定-左侧自适应
<html>
<head>
<title>两拦布局右侧宽度固定-左侧自适应</title>
<style media="screen">
.con{width: 90%; overflow:hidden; border:1px dashed red}
.right{float: right; width:200px; margin-left:-200px; height:400px; background: green}
.left{float:left; width:100%;}
.main{margin-right:200px; height:500px; background: orange}
</style>
</head>