Skip to content

Instantly share code, notes, and snippets.

View darkfe's full-sized avatar
🎯
Focusing

walterzhang darkfe

🎯
Focusing
View GitHub Profile
@darkfe
darkfe / replacer.js
Created November 21, 2012 14:14
simple replacer
function replacer(str, obj){
return str.replace(/@{(\w+)}/g,function($all,$1){
return obj[$1] === 0 ? 0 : (obj[$1] || '');
})
}
@darkfe
darkfe / ctags definitions for Javascript
Created November 22, 2012 02:47 — forked from tim-smart/ctags definitions for Javascript
CTags Definitions for Javascript
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*[ \t]*([,;]|$)/\5/,variable/
@darkfe
darkfe / gist:4160017
Created November 28, 2012 09:02
TrieTree
(function (window, document, ns, undefined) {
var Node = function (data, parentNode) {
this._childCount = 0;
this.data = data;
this.parentNode = parentNode || null;
this.childNodes = {};
};
Node.prototype = {
constuctor : Node,
appendChild : function (data) {
@darkfe
darkfe / gist:5098274
Created March 6, 2013 10:07
十六进制 和rgb 互转
'#fff'.replace(/^#(\w)(\w)(\w)$/,'#$1$1$2$2$3$3').replace(/#|\w{2}/g,function($a,index){
if($a=='#')return 'rgb('
else return parseInt($a,16) + (index == 5 ? ')' : ',');
})
'rgb(255,0,255)'.replace(/[\D]+(\d+)\)?/g,function($a,$1,i){ return (!i?'#':'') + (+$1).toString(16).replace(/^\w$/,'$&$&') })
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@darkfe
darkfe / sublime.cmd
Created April 27, 2013 06:02
sublime text 2 配置小助手
@echo off
title sublime text 2 配置小助手
::st2主程序名称
set sublime_exe=sublime_text.exe
::st2主程序全路径
set exepath=%~dp0%sublime_exe%
#!/bin/bash
function ergodic(){
for file in ` ls $1 `
do
if [ -d $1"/"$file ]
then
ergodic $1"/"$file
else
echo $1"/"$file >> b
fi
@darkfe
darkfe / fiddlerscript.js
Created June 26, 2013 02:47
用fiddlerscript在页面指定位置注入脚本
static function InsertTextToResponseBody(oSession: Session, place:String, text:String){
oSession['ui-backcolor'] = 'Orange';
oSession.utilDecodeResponse();
var rPattern = /'(?:[^\\']|\\.)*'|"(?:[^\\"]|\\.)*"|<(\/?(?:head|body))[^<>]*>/ig;
var oBody = '';
//简单判断一下编码..尼玛
if( /\butf-8\b/.test(oSession.oResponse.headers['Content-Type'].ToLower())){
oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
}else{
oBody = System.Text.Encoding.Default.GetString(oSession.responseBodyBytes);
@darkfe
darkfe / ku6html.html
Created June 27, 2013 05:25
xingming shiye
<style>
#sda_banner{
width:960px;
height:60px;
overflow:hidden;
margin:0 auto;
position:relative;
}
#sda_banner_closebtn{
width:19px;
@darkfe
darkfe / deleteHtmlTag1.js
Last active December 19, 2015 05:49
删除字符串中的html标签
//@vilic
function deleteHtmlTag(htmlStr){
return return htmlStr.replace(/<(script|noscript|style|button)(?:(["'])[\s\S]*\2|[^>])*>[\s\S]+?<\/\1>
/g, "").replace(/<\/?[a-z]+(?:(["'])[\s\S]*\1|[^>])*>/g, "");
}