Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@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>'
}
@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 / 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 / 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 / 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 / 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 / gradle-script-using-ig-json-parser.gradle
Last active July 4, 2016 19:47
Using ig-json-parser in android studio gradle build script.
apply plugin: 'com.android.library'
ext {
generatedSourcesDir = file 'gen/main/java'
}
android {
compileSdkVersion XX
buildToolsVersion "XX"
@xinthink
xinthink / slack-on-repo-starred.js
Last active August 29, 2015 14:26
A LeanEngine function that sends a Slack notification when the given GitHub repo got starred.
// parameters of the function
var repo = request.params.repo; // 'user_or_org/repo_name'
var slackWebhook = request.params.slackWebhook; // e.g. 'https://hooks.slack.com/services/XXX'
var repoUrl = 'https://api.github.com/repos/' + repo;
// Set the following names to match your own scheme
var className = 'RepoStars'; // LeanCloud class for storing repo stars
var fieldRepo = 'repo'; // LeanCloud field to store the repo name
var fieldStars = 'count'; // LeanCloud field to store the count of stars
@xinthink
xinthink / codeship_android_build.sh
Created October 8, 2015 02:34 — forked from PuKoren/codeship_android_build.sh
Codeship Android build script
cd /tmp
pwd
#Download Android SDK from Google and unzip it
wget http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz
tar zxvf android-sdk_r24.1.2-linux.tgz
rm android-sdk_r24.1.2-linux.tgz
#Set extracted SDK location to $PATH so we can use commands
export ANDROID_HOME="/tmp/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
@xinthink
xinthink / README-kotlin-dsl-deps-ext-intro.md
Last active January 21, 2020 06:04
Defining Dependencies in Gradle Kotlin DSL

This's for the article Defining Dependencies in Gradle Kotlin DSL.

If you're using [kotlin-dsl] in a multi-project manner, you may want to define all the dependencies in one place. You can put the files into buildSrc, define dependencies in a compat way like this:

extra.deps {
    "kt"("stdlib-jre7")
    "auto" {
        "common"("com.google.auto:auto-common:0.8")
        "service"("com.google.auto.service:auto-service:1.0-rc3")