Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@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 / 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 / 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 / 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 / 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"
extra.deps {
"support" {
"appCompat"("com.android.support:appcompat-v7:26.0.2")
"design"("com.android.support:design:26.0.2")
}
"picasso"("com.squareup.picasso:picasso:2.5.2")
}
dependencies {
compile(deps["support.appCompat"])
compile(deps["support"]["design"])
compile(deps["picasso"])
}
@xinthink
xinthink / root-build.gradle
Last active November 14, 2017 13:52
Reusable dependencies definition in Groovy
// global definition in root project
ext.versions = [
compileSdk: 26,
targetSdk: 25,
]
ext.deps = [
support: [
appCompat: “com.android.support:appcompat-v7:${versions.supportLibrary}”,
design: “com.android.support:design:${versions.supportLibrary}”,