Skip to content

Instantly share code, notes, and snippets.

View chenkaie's full-sized avatar
:octocat:
Build Something...

Kent Chen chenkaie

:octocat:
Build Something...
View GitHub Profile
nmap - <C-w>-
nmap + <C-w>+
" Define different behavior in left/right window
if has("autocmd")
autocmd BufEnter,BufLeave *
\ if winnr() == 1 |
\ nmap < <C-w><|
\ nmap > <C-w>>|
\ else |
\ nmap < <C-w>>|
#!/bin/bash
# Source global definitions
[ -f /etc/bashrc ] && . /etc/bashrc
[ -f /etc/profile ] && . /etc/profile
export EDITOR=vim
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
@chenkaie
chenkaie / fdhijack.sh
Created December 2, 2011 18:00
Redirect stdin, stdout, stderr of a daemon to /dev/pts/#
#!/bin/sh
#
# Redirect stdin, stdout, stderr of a daemon to /dev/pts/#
#
#################################################################################################################
# Ref: stdio buffering: http://www.pixelbeat.org/programming/stdio_buffering/
# Default Buffering modes:
# stdin -> is always buffered
# stderr -> is always unbuffered
# if stdout is a terminal then buffering is automatically set to line buffered, else it is set to buffered
@chenkaie
chenkaie / gist:2421678
Created April 19, 2012 15:25
Sed example
Try this, 剛好是 14 個連續數字,才會echo出東西
echo "./12M-20120419010203-aaaa-bbb-ccc.log" | sed -n "s/.*-\([0-9]\{13\}\)-.*/\1/p"
echo "./12M-20120419010203-aaaa-bbb-ccc.log" | sed -n "s/.*-\([0-9]\{14\}\)-.*/\1/p"
echo "./12M-20120419010203-aaaa-bbb-ccc.log" | sed -n "s/.*-\([0-9]\{15\}\)-.*/\1/p"
所以你可以判斷stdout吐出來的字串是否有長度不為0來判斷是否match
如下:
@chenkaie
chenkaie / gist:2622512
Created May 6, 2012 14:23
commentPhotoDo
<script type='text/javascript'>
//<![CDATA[
var times= 0;
function commentPhotoDo() {
var tag;
for(var i = 0; i < commentPhotoIds.length; i++){
tag = document.createElement('script');
tag.type = 'text/javascript';
tag.src = 'http://chenkaie.110mb.com/avatar.php?maxheight=60&url='+encodeURIComponent(commentPhotoIds[i].url)+'&id='+encodeURIComponent(commentPhotoIds[i].id)+'&defaultimage='+encodeURIComponent('http://bloggerhacks.googlecode.com/files/No_Photo.PNG');
//tag.src = 'http://bloggerhacks.googlecode.com/files/No_Photo.PNG)';
@chenkaie
chenkaie / download_wretch_album.sh
Last active December 22, 2015 13:59
Description: 無名小站相片打包程式 (download_wretch_album.sh) Ref: http://www.wretch.cc/blog/WretchFAQ/13637278
#!/bin/bash
# Modify below 2 variables if needed
ALBUM_NUM=50
ALBUM_FOLDER="./SambaGhost-data/album/"
cd ${ALBUM_FOLDER}
for (( i = 1; i <= ${ALBUM_NUM}; i++ )); do
echo "==> Create folder ${i}"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
struct timeval g_tvStart, g_tvEnd;
unsigned int g_uiDiff;
void ProfilingStart()
{
g_uiDiff = 0;
/*
* $ gcc countbit.c -o countbit.out
* $ ./countbit.out
* ===============================================================
* <PROFILING> Start : [ProfilingStart] (1414405319.256769)
* <PROFILING> End : [ProfilingEnd] (1414405339.508215) g_uiDiff = 20251,446
* ===============================================================
* ===============================================================
* <PROFILING> Start : [ProfilingStart] (1414405339.508239)
* <PROFILING> End : [ProfilingEnd] (1414405355.221734) g_uiDiff = 15713,495
@chenkaie
chenkaie / 5bupeSphqwy.js
Last active July 6, 2016 02:28
FB video upload parser
if (self.CavalryLogger) {
CavalryLogger.start_js(["xTY7O"]);
}
__d('FileHasher', ['WebWorker', 'fileSliceName', 'emptyFunction', 'FileHashWorkerResource'], function a(b, c, d, e, f, g) {
if (c.__markCompiled) c.__markCompiled();
h.isSupported = function() {
'use strict';
return c('WebWorker').isSupported();
};