Skip to content

Instantly share code, notes, and snippets.

View LiuJi-Jim's full-sized avatar
🏠
Working from home

Liu Ji LiuJi-Jim

🏠
Working from home
View GitHub Profile
@LiuJi-Jim
LiuJi-Jim / Matrix67.2011-2012.Maze.js
Created November 8, 2012 10:11
Matrix67 2011->2012 Maze
// v2.0,避免一个for (in),速度大幅度提高,但graph的构造不如之前优雅,优化了hash,总代码量几乎没有增加,加了点注释。
var ops = ['+7', '/2', '*3', '-5'];
var graph = [
[{e:0,n:1}, {e:1,n:1}],
[{e:0,n:0}, {e:1,n:0}, {e:2,n:2}, {e:3,n:2}],
[{e:2,n:1}, {e:3,n:1}]
]; // 第一维是顶点,第二维是出边,e是边的id,n是指向的顶点。
graph.forEach(function(vex, i){
vex.forEach(function(edge, j){
edge.f = new Function('val', 'return val' + ops[edge.e]); // 把边构造成一个function
@LiuJi-Jim
LiuJi-Jim / extract archive file
Created November 27, 2012 05:46
extract archive file
ex () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
#pl_leftnav_app,
#trustPagelet_checkin_lotteryv5,
#trustPagelet_recom_interestv5,
.gn_title[node-type=app],
.gn_title[node-type=weiba],
.gn_title[node-type=game],
.gn_title[node-type=hot],
.gn_setting[node-type=member],
#pl_rightmod_ads35,
/*#trustPagelet_zt_hottopicv5,*/ /*右侧导航[热门话题]予以保留,不想看这个的可以把这行注释取消掉*/
@LiuJi-Jim
LiuJi-Jim / Outlook空标题检测脚本
Last active December 20, 2015 12:19
Outlook空标题检测脚本
'在Outlook里面,按alt+F11,然后编辑器里搞这个进去
'这样在发送邮件的时候会检测空标题
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeName(Item) <> "MailItem" Then Exit Sub
Dim cancel_Subject As Boolean
Dim cancel_Attach As Boolean
'CHECK FOR BLANK SUBJECT LINE
If Item.Subject = "" Then
cancel_Subject = MsgBox("邮件无标题,依然发送吗?", vbYesNo + vbExclamation, "邮件标题为空") = vbNo
@LiuJi-Jim
LiuJi-Jim / js-hsl.html
Last active December 23, 2015 04:39
JavaScript HSL color generator
<html>
<head>
<style>
#list {
}
.item {
width:15px;
height:10px;
overflow:hidden;
float:left;
@LiuJi-Jim
LiuJi-Jim / js-hsv.html
Created September 16, 2013 17:03
JavaScript HSV color generator
<html>
<head>
<style>
#list {
}
.item {
width:15px;
height:10px;
overflow:hidden;
float:left;
@LiuJi-Jim
LiuJi-Jim / css3-gradient-text.html
Last active December 26, 2015 23:39
CSS3 渐变文字
<!doctype html>
<html>
<head>
<title>CSS3文字渐变</title>
<meta charset="UTF-8">
<style type="text/css">
body {
margin:0;
padding:0;
background:#fff;
@LiuJi-Jim
LiuJi-Jim / bezier.js
Last active July 12, 2020 06:17
De Casteljau Bezier
function DeCasteljauBezier(points, density, step){
//if (points.length < 3) return null;
console.time('bezier');
var ps = points.map(function(p){
return {
x: p.x,
y: p.y
};
}),
results = [],
@LiuJi-Jim
LiuJi-Jim / hrtime.js
Last active October 27, 2015 09:39
HRT(High Resolution Timing) in JavaScript
var hrtime = (function(){
if (typeof window !== 'undefined'){
// browser
if (typeof window.performance !== 'undefined' && typeof performance.now !== 'undefined'){
// support hrt
return function(){
return performance.now();
};
}else{
// oh no..
@LiuJi-Jim
LiuJi-Jim / app.js
Created August 14, 2014 13:18
express.js auto route,遍历controllers目录里的所有js文件,对里面每个module的每个属性都当做一个/:controller/:action,作自动路由(就跟ASP.NET MVC差不多啦!)
// app.js
for (var controller in routes){
var mod = routes[controller];
app.all('/' + controller + ':action', function(req, res){
var action = req.params.action;
if (action in mod){
mod[action](req, res);
}else{
res.statusCode = 404;
res.send('404 not found');