Skip to content

Instantly share code, notes, and snippets.

View mtrung's full-sized avatar
💭
I may be slow to respond.

Trung Vo mtrung

💭
I may be slow to respond.
View GitHub Profile
// Photoshop script to resize canvas and export
// You can add this script to Action for automation
doc = app.activeDocument;
// change the color mode to RGB. Important for resizing GIFs with indexed colors, to get better results
doc.changeMode(ChangeMode.RGB);
// default background color filling in when resizing canvas
var bgColor = new SolidColor();
include ':app'
def includeModules = { String extModuleDir, moduleList ->
// def extModuleDir = 'aw-common'
// def moduleList = ['wear-common', 'engine']
for (String moduleName in moduleList) {
def module = ":" + moduleName
include module
// ...must change projectDir for each module
project(module).projectDir = new File(extModuleDir, moduleName)
@mtrung
mtrung / color.sh
Created October 20, 2015 21:54
echo text in color bash script
#!/bin/bash
start=\\033[
end=\\033[0m
Green=${start}32m
Yellow=${start}33m
Blue=${start}34m
Red=${start}31m
echo_d() {
echo -e "${Blue}${1}${end}"
@mtrung
mtrung / .bash_profile
Created October 20, 2015 17:06
CLI with colors
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -l -GFh'
alias l='ls -l -GFh'
alias ll='ls -la'
alias lm='ls | more'
alias llm='ls -la | more'
export PATH=$PATH:/Users/xxx/Library/Android/sdk/platform-tools/
@mtrung
mtrung / TimezoneHelper.java
Created July 16, 2015 15:30
Get all Timezone IDs
StringBuilder sb = new StringBuilder("---------------");
sb.append("Count = ");
sb.append(TimeZone.getAvailableIDs().length);
sb.append("\n");
Log.i("Time", sb.toString());
for (String timezoneId : TimeZone.getAvailableIDs()) {
sb.replace(0, sb.length()-1, timezoneId);
Log.i("Time", sb.toString() + "\n");
}
@mtrung
mtrung / Android TimeZone Ids
Last active August 23, 2022 09:06 — forked from arpit/Android TimeZone Ids
As of July 2015, there are 582 Java/Android TimeZone Ids. Note that this list is subject to change (there are 23 additions and 2 deletions from 2011 to 2015).
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@mtrung
mtrung / GoogleApiClientManager.java
Created July 2, 2015 22:42
dumpDataset from Google Fit
void dumpDataset(DataSet dataSet) {
if (dataSet.isEmpty()) return;
SimpleDateFormat dateFormat = new SimpleDateFormat();
for (DataPoint dp : dataSet.getDataPoints()) {
String s = String.format("Data point: %s -> %s %s",
dp.getDataType().getName(),
dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)),
dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
Log.i(TAG, s);
@mtrung
mtrung / settings.gradle
Created June 17, 2015 22:12
Gradle/Groovy script to include external modules for Android Studio
// ...include external modules
def extModuleDir = '../shared_modules'
def moduleList = ['mod1', 'mod2']
for (moduleName in moduleList) {
def module = ":" + moduleName
include module
// ...must change projectDir for each module
project(module).projectDir = new File(extModuleDir, moduleName)
println "- include " + module + " path=" + project(module).projectDir.getPath()
@mtrung
mtrung / build.gradle
Created May 20, 2015 16:31
getCurrGitBranch
def getCurrGitBranch = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
standardOutput = code
}
return code.toString().trim()
@mtrung
mtrung / build.gradle
Created May 20, 2015 16:29
getVersionCode
def getVersionCode = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine "git", "rev-list", "HEAD", "--count"
standardOutput = code
}
return code.toString().toInteger()