Skip to content

Instantly share code, notes, and snippets.

@yangg
yangg / TextureSpliter.php
Last active Aug 16, 2017
将 TexturePacker 导出的 json 格式 atlas 拆分
View TextureSpliter.php
<?php
/**
* 将 TexturePacker 导出的 json 格式 atlas 拆分
*/
function spliter($filename) {
$assetFolder = __DIR__;
$destFolder = $assetFolder;
$frames = json_decode(file_get_contents($assetFolder ."/$filename.txt"), true);
@yangg
yangg / filewatcher.py
Last active Dec 16, 2015
Monitoring filesystems events with inotify
View filewatcher.py
#!/usr/bin/env python
# coding: utf-8
# https://github.com/seb-m/pyinotify
from pyinotify import WatchManager, Notifier, ProcessEvent, IN_CREATE, IN_MODIFY, IN_DELETE
import os, sys
class FileHandler(ProcessEvent):
def process_IN_CREATE(self, event):
@yangg
yangg / demo.html
Last active Dec 16, 2015
Cross-Browser Grayscale with CSS
View demo.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=2.0" />
<title>Cross-Browser Grayscale with CSS</title>
<link rel="stylesheet" href="gray.css" />
<style>
body { text-align: center; }
p { color: #f00; font-size: 2em; }
View dabblet.css
/* Pounding heart animation */
@keyframes pound {
to { transform: scale(1.4); }
}
.heart {
display: inline-block;
font-size: 150px;
color: #e00;
View dabblet.css
/**
* Links
*/
body {
background: #FFDEDB;
}
a {
display: inline-block;
@yangg
yangg / array.js
Created Sep 7, 2012
JavaScript implements
View array.js
// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array
/*
* Implemented in JavaScript 1.6
*/
Array.prototype.forEach = Array.prototype.forEach || function(fun /*, thisp*/) {
var len = this.length >>> 0;
if(typeof fun != 'function') { throw new TypeError(fun + ' is not a function'); }
for(var thisp = arguments[1], i = 0; i < len; i++) {
if(i in this) {
@yangg
yangg / dabblet.css
Created Aug 29, 2012
Amazing CSS bubble
View dabblet.css
/**
* Amazing CSS bubble
*/
body { font:14px/1.6 Lucida Grande,Droid Sans,Verdana,Microsoft YaHei; }
.bubble { height: 120px; width: 400px; left: 20%; }
/* bubble core */
.bubble { position: absolute; border: 1px solid #53a8c9; padding: 10px; min-width: 100px;
border-radius: 5px; box-shadow: 0 0 5px 1px #dbf6ff;
background: #FFF; background: -webkit-linear-gradient(bottom, #e8f5ff, #fff 20px);
View linear-gradient.php
<?php
$height = isset($_GET['height']) ? $_GET['height'] : 80;
$width = isset($_GET['width']) ? $_GET['width'] : 80;
// top | left
$dir = isset($_GET['direction']) ? $_GET['direction'] : 'top';
$start = $_GET['start'];
$end = $_GET['end'];
list($r, $g, $b) = hex2rgb($start);
@yangg
yangg / dabblet.css
Created Aug 20, 2012
filter - Learning CSS3
View dabblet.css
/**
* filter - Learning CSS3
*/
dl { float: left; margin: 5px; }
.grayscale img { -webkit-filter: grayscale(100%); }
.sepia img { -webkit-filter: sepia(100%); }
.saturate img { -webkit-filter: saturate(200%); }
.invert img { -webkit-filter: invert(100%); }
.brightness img { -webkit-filter: brightness(1%); }