Skip to content

Instantly share code, notes, and snippets.

View dyng's full-sized avatar
🤔
I think

Ye Ding dyng

🤔
I think
  • Shanghai
  • 06:14 (UTC +08:00)
View GitHub Profile
@dyng
dyng / gist:4265896
Created December 12, 2012 07:49
比较两个json是否等价(perl版)
#! /usr/bin/env perl
use warnings;
use strict;
use utf8;
use JSON::XS;
use Data::Compare;
use Path::Class;
my ($a_json, $b_json) = @ARGV;
@dyng
dyng / gist:4233046
Created December 7, 2012 12:48
把多个input框的内容拼接成一条字符串
var serial_code = $("#serial-code-input>input").map(function(){
return this.value;
}).get().join('');
@dyng
dyng / gist:4215016
Created December 5, 2012 12:03
通过绝对路径import模块
def import_path(fullpath):
"""
Import a file with full path specification. Allows one to
import from anywhere, something __import__ does not do.
"""
path, filename = os.path.split(fullpath)
filename, ext = os.path.splitext(filename)
sys.path.append(path)
module = __import__(filename)
reload(module) # Might be out of date
@dyng
dyng / gist:4199450
Created December 4, 2012 00:42
vim光标位置的备份和恢复
(line_bak, col_bak) = (vim.eval("line('.')"), vim.eval("col('.')"))
"""
do something
"""
vim.command("call cursor('{0}', '{1}')".format(line_bak, col_bak))
@dyng
dyng / sprymap.html
Created November 12, 2012 09:15
Click and Drag
<div class="mappy" style="overflow: hidden; width: 800px; height: 400px; position: relative; cursor: auto;">
<img id="worldMap" alt="A map of the world." src="map.jpg" style="position: absolute; left: -141px; top: -272px;">
</div>
@dyng
dyng / gist:3904747
Created October 17, 2012 09:53
create file from script with inline content
cat > path/to/outfile <<DELIM # DELIM can be any delimiter
hello line 1
hello line 2
bye
DELIM