Skip to content

Instantly share code, notes, and snippets.

@panweizeng
panweizeng / getmaxsub.js
Last active July 7, 2017 01:36
编写函数获取两个字符串的最长公共子串,例如: s1 = GCCCTAGCCAGDE,s2 = GCGCCAGTGDE,它们的最长公共子串是 GCCAG。
function getMaxSub(s1, s2) {
var max = 0, retchars = [];
for(var index = 0; index < s1.length; index++){
var count = 0, chars = []; // 每次遍历都置空
debug('============%d============', index);
for(var i = index, j = 0; j < s2.length; j++){
var s1char = s1[i];
var s2char = s2[j];
debug(s1char, s2char, s1char === s2char);
if(s1char === s2char){
@panweizeng
panweizeng / iciba.css
Last active December 16, 2015 11:08
stylish style for iciba
body,
.dict_title,
.iCiBa_open_suggest,
.iCiBa_open_suggest_input { font-family:Adelle!important; }
#icibaSugContent li { padding-left:10px!important; }
#main_box { width:824px!important;}
#dict_main, .dictbar { width:824px!important; }
#dict_main { width:inherit!important; }
#side_bar { display:none!important; } /*右侧推荐*/
@panweizeng
panweizeng / gist:2489832
Created April 25, 2012 13:48
drawsomething
#!/usr/bin/env php
<?php
$all = 'abba
acdc
ace
acorn
add
adele
africa
@panweizeng
panweizeng / gist:2472157
Last active January 10, 2017 04:29
evernote:在日志notebook下自动创建当天日期的note
--在Automator新建Service,Utilities选Run AppleScript,粘帖以下代码,保存命名为evernote-diarynew
--在System Prefrences > Keyboard > Application Shortcut,点+号新增
--Application选Evernote, Menu Title写evernote-diarynew, Keyboard Shortcut自选,推荐Command+D
on run {input, parameters}
set yearStr to do shell script "date +%Y"
set dateStr to do shell script "date +%Y-%m-%d"
set diaryNotebook to "[日志-" & yearStr & "]"
set searchQuery to ("notebook:" & diaryNotebook & " intitle:" & dateStr) as string
set searchQueryCollection to ("notebook:" & diaryNotebook) as string
@panweizeng
panweizeng / gist:936828
Created April 22, 2011 14:59
show git branch name in prompt
PS1="[\u@\h:\W\[\033[0;32m\]\$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')\033[0m]\$ "