Skip to content

Instantly share code, notes, and snippets.

@bhurling
bhurling / FlagToEmoji.kt
Last active September 14, 2022 04:30
Kotlin way of converting country codes to emoji flags
import java.util.Locale
fun countryCodeToEmojiFlag(countryCode: String) {
return countryCode
.toUpperCase(Locale.US)
.map { char ->
Character.codePointAt("$char", 0) - 0x41 + 0x1F1E6
}
.map { codePoint ->
Character.toChars(codePoint)
@bhurling
bhurling / build.gradle
Created November 6, 2015 15:26
Provide a comma-separated list of flavors to publish
if (hasProperty("publishFlavors") && hasProperty("publishTypes")) {
afterEvaluate {
publishFlavors.splitEachLine(",") {
it.each { flavor ->
publishTypes.splitEachLine(",") {
it.each { type ->
publish.dependsOn "publish${type.capitalize()}${flavor.capitalize()}Release"
}
}
}
@bhurling
bhurling / MainActivity.java
Last active August 29, 2015 14:08
Weird activity transition hickup.
public class MainActivity extends Activity implements View.OnClickListener {
View mView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mView = findViewById(R.id.view);
@bhurling
bhurling / OverlayBackground.java
Last active August 29, 2015 14:00
Convenience factory for creating fullscreen backgrounds that are partially transparent and may contain multiple circular punch holes to let the lower layers shine through.
package com.exmaple.overlay;
import android.app.Activity;
import android.graphics.*;
import android.graphics.drawable.BitmapDrawable;
/**
* Convenience factory for creating fullscreen backgrounds that are partially transparent and may contain
* multiple circular punch holes to let the lower layers shine through. </br></br>
*