Skip to content

Instantly share code, notes, and snippets.

View patrickhammond's full-sized avatar

Patrick Hammond patrickhammond

View GitHub Profile
@patrickhammond
patrickhammond / snippet.java
Created June 23, 2016 20:08
Tinting a map marker.
Bitmap markerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.mapmarker);
Bitmap resultBitmap = Bitmap.createBitmap(markerBitmap, 0, 0, markerBitmap.getWidth() - 1, markerBitmap.getHeight() - 1);
ColorFilter filter = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
Paint markerPaint = new Paint();
markerPaint.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(resultBitmap, 0, 0, markerPaint);
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(resultBitmap));
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
public final class ColorUtils {
public static int blendColors(
@ColorInt int firstColor,
@ColorInt int secondColor,
@FloatRange(from = 0.0, to = 1.0f) float percentage) {
int firstAlpha = Color.alpha(firstColor);
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.util.SparseArrayCompat;
import android.view.ViewGroup;
public abstract class IndexedFragmentPagerAdapter<T> extends FragmentPagerAdapter {
private SparseArrayCompat<T> fragments = new SparseArrayCompat<>();
public IndexedFragmentPagerAdapter(FragmentManager fm) {
super(fm);
public class MainActivity extends ActionBarActivity {
private static final String QUANTITY = "quantity";
private int quantity = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@patrickhammond
patrickhammond / commands.sh
Last active April 30, 2018 21:04
Useful video scripts
# Joining video files
ls *.MP4 | sort | awk '{print "file \x27" $0 "\x27"}' > concat.txt
ffmpeg -f concat -i concat.txt -c copy output.mp4
# Quicktime to MP4
ffmpeg -i Untitled.mov -vcodec copy -acodec copy out.mp4
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The smarter thing to do would be to use what is Guava, etc...but Guava is a big fat library that
* will blow the dex count and this is pretty much the only thing we are using out of it.
*
android {
lintOptions {
abortOnError true
lintConfig file("${project.rootDir}/config/lint/lint.xml")
htmlReport true
}
}
StrictMode policy violation; ~duration=1436 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=1114143 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1263)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:67)
at java.io.File.doAccess(File.java:281)
at java.io.File.exists(File.java:361)
at android.app.ContextImpl.createFilesDirLocked(ContextImpl.java:418)
at android.app.ContextImpl.getCacheDir(ContextImpl.java:503)
at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:233)
export PS1="\[$(tput bold)\]\[$(tput setaf 6)\]\t \[$(tput setaf 2)\][\[$(tput setaf 3)\]\u\[$(tput setaf 1)\]@\[$(tput setaf 3)\]\h \[$(tput setaf 6)\]\W\[$(tput setaf 2)\]]\[$(tput setaf 4)\]\\$ \[$(tput sgr0)\]"
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home # Update to latest
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/22.0.1:$PATH # Update to latest
@patrickhammond
patrickhammond / command.sh
Last active October 26, 2016 20:01
Using ffmpeg to join multiple video files. 1:14:48 1080p video (14.14GB) joined in under 1min.
ffmpeg -f concat -i concat.txt -c copy output.mp4