Skip to content

Instantly share code, notes, and snippets.

View kindy's full-sized avatar

Kindy Lin kindy

  • Beijing, China
  • 01:19 (UTC +08:00)
  • LinkedIn in/kindy
View GitHub Profile
var args = {};
(location.search || '').replace(/^\?/, '').replace(/([^&=]*)(?:=([^&]*))?/g, function(m, k, v) {
if (v) {
args[k] = decodeURIComponent(v);
}
return '';
});
@kindy
kindy / a.ltp
Created June 24, 2012 14:55
在 ngx_lua 中实现类似 php 的被嵌入 html 功能
"abc"
<?= 124 ?>
<?= a ?>
<? local x = 12
if math.random(1, 5) > 1 then ?>
xxx
<? else ?>
yyy
<? end ?>
@kindy
kindy / arbase.lua
Created June 11, 2012 12:17 — forked from stuartpb/arbase.lua
Function for using arbitrary digit systems to convert numbers to strings
local function base (digit_list)
local b = #digit_list
if b == 0 then
return function(number) return "" end
elseif b == 1 then
local mark = digit_list[1]
return function(number)
return string.rep(mark, number)
end
else
//调用idIncrement(“quizForm.quiz.questions[0].options[0].textContent” , "questions")的时候返回
// quizForm.quiz.questions[1].options[0].textContent
//调用idIncrement(“quizForm.quiz.questions[0].options[0].textContent” , "options")的时候返回
// quizForm.quiz.questions[0].options[1].textContent
function idIncrement(s,p){
return s.replace(new RegExp('(' + p + '\\[)(\\d+)\\]'), function($a,$1,$2){
return $1 + ((parseInt($2, 10) || 0) + 1) + ']';
});
}