Skip to content

Instantly share code, notes, and snippets.

View .update_filenametags.bat
cd $project
ctags -e -R --languages=php -f tags . E:/IDKin/iCoreServer/res/IDKin/PHP_Resources
find . -not -regex ".*\/\(\.svn\|images\|temp\)\/.*" -type f -printf "%f\t%p\t1\n" | sort -f >.filenametags
exit 0
# vim: ft=sh
@yangg
yangg / .vimrc
Created Jul 2, 2011
Compile JavaScriptLint
View .vimrc
" add to .vimrc
function! Make()
if &modified | silent write | endif
if &makeprg == 'make' | return | endif
silent make
execute 'cw'
endfunction
autocmd Filetype javascript setlocal makeprg=jsl\ -nologo\ -nofilelisting\ -nosummary\ -nocontext\ -conf\ /etc/jsl.conf\ -process\ % |
@yangg
yangg / gist:1062232
Created Jul 3, 2011
Shell scripts(Ubuntu)
View gist:1062232
Mint
# screenlets
# Show bandwidth use oneliner
while true; do cat /proc/net/dev; sleep 1; done | awk -v dc="date \"+%T\"" '/eth0/{i = $2 - oi; o = $10 - oo; oi = $2; oo = $10; dc|getline d; close(dc); if (a++) printf "%s %8.2f KiB/s in %8.2f KiB/s out\n", d, i/1024, o/1024}'
# limit the cpu usage of a process
sudo cpulimit -p pid -l 50
# ubuntu root
@yangg
yangg / formatsize.cs
Created Sep 26, 2011
Format Filesize
View formatsize.cs
// http://www.cnblogs.com/yaob/archive/2011/05/14/2046013.html
public string formatSize(long size)
{
if (size == 0) return "0";
string[] sizetext = new string[] { "B", "KB", "MB", "GB", "TB", "PB" };
int i = (int)Math.Floor(Math.Log(size, 1024));
return Math.Round(size / Math.Pow(1024, i), 2).ToString() + " " + sizetext[i];
}
@yangg
yangg / zswang.js
Created Oct 6, 2011
js正则匹配数组中不重复的元素
View zswang.js
var arr=["a","b","c","a","ba","bc"];
alert(arr.join(",").match( /([^,]+)(?!.*,\1(,|$))/ig));
Array.prototype.deleteEle=function(){
var arr=this,o={},newArr=[],i;
for( i=0;i<arr.length;i++){
if(typeof(o[arr[i]])==="undefined"){
newArr[newArr.length]=arr[i]
}
@yangg
yangg / background.html
Created Nov 15, 2011
Open Frame in New Tab in Chrome
View background.html
<!DOCTYPE HTML>
<html>
<script>
function createMenu() {
chrome.contextMenus.create({
title: "Open &Frame in New Tab",
onclick: function(info, tab) {
chrome.tabs.create({
url: info.frameUrl || info.pageUrl,
index: tab.index + 1,
View realpath.c
// realpath.c: display the absolute path to a file or directory.
// Adam Liss, August, 2007
// This program is provided "as-is" to the public domain, without express or
// implied warranty, for any non-profit use, provided this notice is maintained.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <limits.h>
View background.html
<!DOCTYPE HTML>
<html>
<script>
chrome.experimental.webRequest.onResponseStarted
.addListener(function(details) {
console.log(details.url);
}
, {urls: ["*://*/*.mp3", "*://*/*.mp4", "*://*/*.flv", "*://*/*.webm"]}
);
</script>
@yangg
yangg / sleep.cs
Created Dec 10, 2011
延时函数(不假死)
View sleep.cs
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
static extern uint GetTickCount();
static void Delay(uint ms) {
uint start = GetTickCount();
while (GetTickCount() - start < ms) {
Application.DoEvents();
}
@yangg
yangg / cssprimitievalue.html
Created Dec 18, 2011
CSSPrimitiveValue & RGBColor
View cssprimitievalue.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>CSSPrimitiveValue & RGBColor</title>
</head>
<body>
<div id="panel1" style="background-color:#09c;"> test</div>
</body>
<script>