Skip to content

Instantly share code, notes, and snippets.

@AlexMeuer
AlexMeuer / boost_installer.bat
Created April 6, 2017 13:58
Interactive script to install C++ BOOST library for Visual Studio 2013 or 2015
@echo off
title Boost Installer --- C00165681 v1.0
color a
echo Copyright (c) 2016 Alexander Meuer
echo.
echo Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
echo.
echo The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
echo.
echo THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CO
@AlexMeuer
AlexMeuer / set_sail.sh
Last active June 22, 2018 11:14
Pipe some input to and set sail! UPDATE: Now works on MacOS (tested with iTerm) and no longer clutters terminal history! :D
#!/bin/bash
# Name: set_sail
#
# Description: This is a little script to make terminal output less dull.
# Just direct stuff into the scripts stdin and you'll set sail!
# Output can be slowed by passing --slow or -s as the first argument, you can also,
# optionally, specify how long to wait between outputs if using the slow options.
#
# Example use: cat <some_file> | set_sail --slow 1
@AlexMeuer
AlexMeuer / html_image_map_to_json.py
Last active August 1, 2017 08:48
Converts a html image map into a json array where (optionally) each coordinate is transformed into a percentage (0.0 -> 1.0) based on the given width and height.
#!/usr/bin/env python
from __future__ import division
import sys
import argparse
import xml.etree.ElementTree as ET
import os.path
py3 = sys.version_info[0] > 2 # Check if python2 or python3
@AlexMeuer
AlexMeuer / HighlightableBitmapDrawable.java
Created August 9, 2017 11:01
Simple Drawable extension to allow highlighting regions of a single image. Also allows an overlay to be drawn on top of the selection (I've use a bitmap for the overlay, but using a color instead is straightforward and follows the same technique as darkening the surrounding area).
package foo.bar;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.ColorRes;
@AlexMeuer
AlexMeuer / SequentialFileDownloader.java
Created August 15, 2017 09:08
Downloads files one by one to the app's internal storage. Logs a warning if a file already exists but does not stop the download. Uses guava for string testing.
package foo.bar
import android.content.Context;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import android.util.Log;
import com.google.common.base.Strings;
@AlexMeuer
AlexMeuer / CustomFontTextView.java
Created September 6, 2017 10:23
Basic extension of Android's TextView to allow declaring the use of custom fonts via xml. Assumes fonts are inside 'assets/fonts/' but this can be changed in `applyFont(..)`.
package foo.bar.baz;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import foo.bar.R;
@AlexMeuer
AlexMeuer / LatoTextView.java
Created February 5, 2018 13:53
Adaptation of https://gist.github.com/AlexMeuer/fb38958e1f154a0fef4e9738df83a49c for a single font. No need to add xml attributes for the same font everywhere if you can just swap out all the TextViews with a custom class.
package foo.bar.baz;
import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.IntDef;
import android.util.AttributeSet;
import com.google.common.collect.ImmutableMap;
import java.lang.annotation.ElementType;
@AlexMeuer
AlexMeuer / Background.java
Created February 7, 2018 11:03
Very simple utility class for running stuff on an executor. Depends on Google Guava (written with 'com.google.guava:guava:23.3-android')
package foo.bar.baz;
import android.support.annotation.CheckResult;
import android.support.annotation.NonNull;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.concurrent.Callable;
@AlexMeuer
AlexMeuer / ViewUtil.java
Created February 7, 2018 11:15
Utility class for performing common color animations on Views. (Use of `MoreObjects` can be replaced with a turnary if you really hate Guava.)
package foo.bar.baz;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;

Keybase proof

I hereby claim:

  • I am alexmeuer on github.
  • I am alexmeuer (https://keybase.io/alexmeuer) on keybase.
  • I have a public key ASD06fODX_mVCYdBLG2-PCxeWrgVL_riC2ITz16s8sJAtQo

To claim this, I am signing this object: