Skip to content

Instantly share code, notes, and snippets.

View ktmud's full-sized avatar
🥌
Peace and Love~

Jesse Yang ktmud

🥌
Peace and Love~
View GitHub Profile
/**
* 统计埋点代码
* @author 丘迟 <[email protected]>
*/
(function(S, win, doc, undefined) {
var E = S.Event;
//默认的前缀
//可以通过在后面的脚本修改全局变量来动态修改
win.STAT_PREFIX = 'http://www.atpanel.com/search?';
@ktmud
ktmud / alias.sh
Created October 16, 2013 10:41
Git svn pre dcommit hoos
real_git=$(which git)
git () {
curr_branch=$($real_git branch | sed -n 's/\* //p')
if [[ ($curr_branch != master && $1 == 'svn' && $2 == 'dcommit') ]]
then
if [[ $($real_git svn info | grep trunk) ]]; then
echo "You are in svn trunk, but not on git master."
echo "Exit."
echo ""
@ktmud
ktmud / pinyin-search.js
Created January 6, 2014 07:11
拼音匹配
var data = [{
text: '我们都是好孩子',
pinyin: 'wo men dou shi hao hai zi'.split(' ')
}, {
text: '我没有病',
pinyin: 'wo mei you bing'.split(' ')
}, {
text: '我们都好',
pinyin: 'wo men dou hao'.split(' ')
}]
@ktmud
ktmud / anim.coffee
Last active August 29, 2015 13:56
Enable `animate.css` with jQuery animation queue
ANIMATION_END = "webkitAnimationEnd mozAnimationEnd
MSAnimationEnd oanimationend
animationend"
$.fn.anim = (cls, options, nextDelay) ->
@removeClass("animated #{@data('_last_anim')}")
@data '_last_anim', cls
if 'number' is typeof options
options = { duration: "#{options/1000}s" }
if options?
@ktmud
ktmud / gulpfile.js
Last active February 28, 2022 10:39
An example gulpfile.js with bower components and live reload support
var BatchStream = require('batch-stream2')
var gulp = require('gulp')
var coffee = require('gulp-coffee')
var uglify = require('gulp-uglify')
var cssmin = require('gulp-minify-css')
var bower = require('gulp-bower-files')
var stylus = require('gulp-stylus')
var livereload = require('gulp-livereload')
var include = require('gulp-include')
var concat = require('gulp-concat')
@ktmud
ktmud / trunc.js
Created April 3, 2014 10:18
trunc text based on locale
String.prototype.blength = function() {
return this.replace(/\n\r/g, '\n').replace(/[^\x00-\xff]/g, 'xx').length;
};
function btrunc(text, limit) {
limit = Number(limit) || 10
if (text.blength() < limit * 2) {
return text
}
var ret = '', count = 0, i = 0, max = limit * 2 - 2
@ktmud
ktmud / search.coffee
Last active August 29, 2015 14:01
amap api autocomplete with Typeahead
TT_TEMPLATES =
suggestion: (d) ->
"<p>#{d.name} <small class=\"district\">#{d.district}</small></p>"
map = new AMap.Map elem, level: 4
map.plugin ['AMap.Autocomplete'], =>
bb = new Bloodhound
datumTokenizer: (d) -> [d.name, d.district]
@ktmud
ktmud / acs.R
Created February 23, 2017 19:38
Generate Census Indicators with R
library(zipcode)
library(magrittr)
library(dplyr)
library(stringr)
library(acs)
# load all zipcodes
data(zipcode)
kAPIKey <- "YOUR API KEY"
@ktmud
ktmud / plagiarism.R
Last active March 26, 2017 01:39
Simple Bulk Plagiarism Detector with String Distance
library(stringdist)
library(stringr)
library(dplyr)
library(readr)
kSourceDir <- "~/Downloads/assignments"
ReadFiles <- function(path) {
files <- list.files(path)
ret <- str_c(path, "/", files) %>%