Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@xinthink
xinthink / tb-nav-auto-activation.coffee
Created May 20, 2013 10:35
bootstrap navbar auto activation in coffeescript
# get relative path of URL
getPath = (url) ->
path = url.split(window.location.host)[1] or '/'
path + if path.match '/$' then '' else '/' # ensure endsWith '/'
# check whether p is parent of path (starts with)
parentOf = (p, path) ->
unless p is '/' then path.match '^' + p
else p == path # '/' should not matches any path
@xinthink
xinthink / connect-mongolab
Created April 16, 2013 11:28
Connect mongolab using mongo shell in a heroku app.
#!/bin/bash
mongoctl connect `heroku config | grep -Po '(?<=MONGOLAB_URI: ).+'`
@xinthink
xinthink / ekill
Created April 2, 2013 08:17
Kill process by match the whole command line (like ps -ef) Usage: ekill <pattern> [signal]
#!/bin/bash
SIG="-2"
if [[ "$2" != "" ]]; then
SIG="$2"
fi
ps -ef | grep $1 | grep -v grep | awk '{print $2}' | xargs kill $SIG
@xinthink
xinthink / clean-logs
Created March 26, 2013 03:30
Remove log files older than 30 days.
find logs -name "*.log" -mtime 30 -exec rm {} \;
@xinthink
xinthink / gaelyk-build.gradle
Created May 25, 2012 07:56
Gradle build script for gaelyk projects
apply from: "$snippetsRepo/gaelyk-prj.gradle"
buildscript {
apply from: "$snippetsRepo/gaelyk-buildscript.gradle"
}
@xinthink
xinthink / gradle-dependencies-github.gradle
Created April 4, 2012 10:30
gradle dependencies resolving against GitHub download url
repositories {
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = 'GitHub'
addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
}
}
dependencies {
classpath '<githubId>:<artifact>:<revision>'
}