Skip to content

Instantly share code, notes, and snippets.

View chemzqm's full-sized avatar
🇨🇳
Focusing

Qiming zhao chemzqm

🇨🇳
Focusing
View GitHub Profile
" toggle unite, quickfix list and location list
if exists("g:loaded_toggle_list")
finish
endif
let g:loaded_toggle_list = 1
function! s:GetBufferList()
redir =>buflist
silent! ls
" Jump previous/next according to existence of unite, quickfix list, location list
" make sure only one list is opening
function! s:Filter(name)
return a:name =~# '\v\[(Location List|Quickfix List)\]'
endfunction
function! s:GetBuffer()
redir =>buflist
silent! ls
@chemzqm
chemzqm / quickfix.vim
Created December 19, 2015 10:58
Unite quickfix
scriptencoding utf-8
function! unite#sources#quickfix#define()
return s:source
endfunction
let s:source = {
\ "name" : "quickfix",
\ "description" : "output quickfix",
\ "syntax" : "uniteSource__Quickfix",
@chemzqm
chemzqm / location_list.vim
Last active December 19, 2015 15:51
location_list for unite
scriptencoding utf-8
function! unite#sources#location_list#define()
return s:source
endfunction
let s:source = {
\ "name" : "location_list",
\ "description" : "output location_list",
\ "syntax" : "uniteSource__LocationList",
@chemzqm
chemzqm / grepprg.sh
Created December 20, 2015 10:13
git grep with column and new files
#! /bin/bash
git --no-pager grep --no-color --no-index --exclude-standard -n $1 | while read git_grep; do
file_and_line=$(echo "$git_grep" | cut -d : -f 1,2)
match=$(echo "$git_grep" | sed 's/[^:]*:[^:]*:\(.*\)/\1/')
column=$(echo "$match" | awk "{print index(\$0, \"$1\")}")
echo "$file_and_line:$column:$match"
done
@chemzqm
chemzqm / client.js
Created October 23, 2013 10:44
后端导出svg为png到前端, image.js为express路由,rasterize.js为phantomjs运行文件,client.js为前端发送请求生成png文件请求的代码
var chart = highchart(this.el, opts).highcharts();
var svg = chart.getSVG();
request
.post('/image')
.send({
xml: svg
})
.set('Accept', 'application/json')
.end(function(err, res) {
if(err) throw err;
@chemzqm
chemzqm / focusmacvim
Last active December 26, 2015 11:41
some osascript
#!/bin/sh
osascript <<END
tell application "MacVim"
activate
end tell
END
@chemzqm
chemzqm / format.js
Created October 30, 2013 05:46
pretty error format for node
require('longjohn')
var prettyjson = require('prettyjson')
function formatJson(object) {
// adds 4 spaces in front of each line
var json = prettyjson.render(object)
json = json.split('\n').join('\n ')
return ' ' + json
}
function playNiceError(error) {
// remove longjohn properties that break prettyjson
@chemzqm
chemzqm / statusline.vim
Created January 2, 2016 19:20
my statusline plugin
function! MyStatusSyntaxItem()
return synIDattr(synID(line("."),col("."),1),"name")
endfunction
function! MyStatusLine()
return "%2*%3.3{MyStatusModeMap()}%*"
\. s:GetPaste()
\. "%4*%0{MyStatusBranch()}%*"
\. " %f " . s:GetModifySymbol()
@chemzqm
chemzqm / gist:8469002
Last active January 3, 2016 13:19
点乐内嵌广告js调用后端测试代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>webview ad for testing</title>
</head>
<body>
<div id="info">info</div>
<div id="download">download</div>