This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To check if a folder exists or not, and to write to the file | |
// Create a File object representing the folder 'A/B' | |
def folder = new File( 'A/B' ) | |
// If it doesn't exist | |
if( !folder.exists() ) { | |
// Create all folders up-to and including B | |
folder.mkdirs() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To upload a jar via gradle you must declare that jar as a publish artifact and add it to a specific configuration using the artifacts closure: | |
apply plugin:'maven' | |
configurations{ | |
allJars | |
} | |
artifacts{ | |
allJars file("path/to/jarFile.jar") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get the current branch name | |
*/ | |
def getCurrentBranchName = { -> | |
def stdout = new ByteArrayOutputStream() | |
exec { | |
commandLine 'git', 'symbolic-ref', 'HEAD', '--short' | |
standardOutput = stdout | |
} | |
return stdout.toString().trim() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ab -n 1000 -c 100 http://localhost:6785/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 100 requests | |
... | |
Finished 1000 requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configurations { | |
apt | |
} | |
dependencies { | |
compile 'com.squareup.dagger:dagger:1.1.0' | |
apt 'com.squareup.dagger:dagger-compiler:1.1.0' | |
} | |
android.applicationVariants.all { variant -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The name of the package. Also used as the name uploaded to the maven repo. | |
*/ | |
def artifactId='DemoApp' | |
/* | |
* The group definition. | |
*/ | |
def groupId='com.lifuzu.app' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* The platform OS definition. | |
*/ | |
def getPlatformOS() { | |
def os = System.properties['os.name'].toLowerCase() | |
// by default we set the platform as 'linux' | |
def platform = 'linux' | |
// on Mac OS, System.properties['os.name'] return 'Mac OS X' | |
if (os.contains('mac')) { | |
platform = 'darwin' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildlogcmd { | |
log=$1 | |
shift | |
echo "Build: $*" >> "$log" | |
echo " `pwd`" >> "$log" | |
echo " `date`" >> "$log" | |
echo "" >> "$log" | |
$* 2>&1 | tee -a "$log" | |
status=${PIPESTATUS[0]} | |
if [ $status != 0 ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
parse_git_remote() { | |
git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD 2> /dev/null) 2> /dev/null | |
} | |
render_git_info() { | |
branch=$(parse_git_branch) | |
if [ $branch ]; then | |
echo "($(parse_git_remote)->$(parse_git_branch))" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while read dbname; do dbarray+=("$dbname"); done < <(mysql -u username -ppassword -e 'show databases;' -B | grep reviewdb) | |
echo ${dbarray[*]} | |
for dbname in `echo ${dbarray[*]}`; do echo $dbname; done |