Skip to content

Instantly share code, notes, and snippets.

View manxisuo's full-sized avatar
🎯
Focusing

Su Yun manxisuo

🎯
Focusing
View GitHub Profile
@manxisuo
manxisuo / fibonacci.py
Created June 4, 2015 13:50
斐波那契数列生成器
def fibonacci():
a = b = 1
yield a
yield b
while True:
a, b = b, a + b
yield b
@manxisuo
manxisuo / dabblet.css
Last active August 29, 2015 14:16
Manxisuo's Test!
/**
* Manxisuo's Test!
*/
background: linear-gradient(45deg, #f06, yellow);
background: #fff;
min-height: 100%;
@manxisuo
manxisuo / JTPool.js
Last active August 29, 2015 13:57
JTPool: A JavaScript Thread Pool (一个JavaScript线程池)
(function() {
const INITIAL = 0;
const RUNNING = 1;
var inDebugMode = false;
function JTPool(maxThread) {
this.status = INITIAL;
this.workQueue = []; // workQueue = [{id: xx, task: xx}]
this.max = (undefined == maxThread) ? 3 : maxThread;
@manxisuo
manxisuo / JXParser.js
Last active August 29, 2015 13:57
Convert JSON to XML & Convert XML to JSON (JSON和XML相互转化)
/*
使用方法:
1. 将XML转为JS对象:
JXParser.xml2Json(xml);
2. 将JS对象或JSON字符串转为XML:
JXParser.xml2Json(xml);
*/
@manxisuo
manxisuo / Template.js
Created December 9, 2013 16:37
12行代码实现简易Javascript模板引擎
;(function (window) {
function Template(str) {
this.str = str;
}
Template.prototype.format = function () {
var arg = arguments[0] instanceof Array ? arguments[0] : arguments;
return this.str.replace(/\{(\d+)\}/g, function (a, b) {
return arg[b] || '';
});
}
@manxisuo
manxisuo / handleBatch.js
Created November 18, 2013 18:35
顺序处理批量任务
/**
* @arr 待处理数组
* @handler 处理函数
*/
function handleBatch(arr, handler) {
// 参数校验
if (!arr || arr.length == 0 || !handler) return;
// 如果没有回调,则直接用循环;
@manxisuo
manxisuo / restart_jekyll.sh
Created July 24, 2013 17:32
用来重启jekyll的脚本
#!/bin/sh
cd ~/git/blogger
export tmp=`ps -ef |grep jekyll|head -n1|awk '{print $2}'`
kill -9 $tmp
rm -rf _site
jekyll serve &
@manxisuo
manxisuo / FindTextInDir.sh
Created July 23, 2013 16:02
在文件夹中搜索文本
# find 文件路径 -name '文件名称模板' | xargs grep '包含的特定文本模板'
find ./ -name '*' | xargs grep 'hello'
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ST</groupId>
<artifactId>ai</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- Shared version number properties -->
<properties>
<org.springframework.version>3.0.0.RELEASE</org.springframework.version>
</properties>
@manxisuo
manxisuo / ellipsis.css
Created May 7, 2013 18:01
CSS 省略号
selector {
width: 270px;
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}