Skip to content

Instantly share code, notes, and snippets.

@Kevinrob
Kevinrob / clean.md
Last active September 19, 2022 17:18
Clean up microk8s registry
View clean.md
registry=localhost:32000
repositories=$(curl ${registry}/v2/_catalog)
for repo in $(echo "${repositories}" | jq -r '.repositories[]'); do
  echo $repo
  tags=$(curl -sSL "http://${registry}/v2/${repo}/tags/list" | jq -r '.tags[]')
  for tag in $tags; do
    echo $tag
    curl -v -sSL -X DELETE "http://${registry}/v2/${repo}/manifests/$(
 curl -sSL -I \
@Kevinrob
Kevinrob / intentChooser.kt
Last active September 30, 2020 16:16 — forked from mediavrog/gist:5625602
Filter out Intents you don"t want to show from a IntentChooser dialog. For example your own app, competing apps or just apps you have a share integration by SDK already :)Based on http://stackoverflow.com/questions/5734678/custom-filtering-of-intent-chooser-based-on-installed-android-package-name/8550043#8550043
View intentChooser.kt
fun Intent.createChooserFiltered(context: Context, filter: (ResolveInfo) -> Boolean): Intent {
val results = context.packageManager.queryIntentActivities(this, 0)
.filter { filter(it) }
.toMutableList()
if (results.isNotEmpty()) {
val intents = results.map {
(this.clone() as Intent).apply {
`package` = it.activityInfo.packageName
setClassName(
View combinatorics.kt
fun main(args: Array<String>) {
val result = combine(arrayOf(3, 2, 3, 5))
// Print result
result.forEach {
it.forEach { System.out.print("$it ") }
System.out.println()
}
}
View SnappingLinearLayoutManager.kt
class SnappingLinearLayoutManager(val context: Context) : LinearLayoutManager(context) {
override fun smoothScrollToPosition(recyclerView: RecyclerView?, state: RecyclerView.State?, position: Int) {
val smoothScroller = object : LinearSmoothScroller(context) {
override fun getVerticalSnapPreference(): Int = SNAP_TO_START
override fun computeScrollVectorForPosition(targetPosition: Int): PointF
= this@SnappingLinearLayoutManager.computeScrollVectorForPosition(targetPosition)
}
smoothScroller.targetPosition = position
startSmoothScroll(smoothScroller)
}
@Kevinrob
Kevinrob / PlayingCards.kt
Created April 2, 2016 19:12
A very simple example of Kotlin
View PlayingCards.kt
enum class CardSymbol {
Hearts, Tiles, Clovers, Pikes
}
class Card(symbol: CardSymbol, value: Int) {
var symbol = symbol
protected set
var value = value
protected set
View NoBugUrlTileProvider.java
public class NoBugUrlTileProvider implements TileProvider {
protected final UrlTileProvider mUrlTileProvider;
public static final byte[] TRANSPARENT_TILE;
static {
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(256, 256, conf);
Canvas canvas = new Canvas(bmp);
canvas.drawColor(0);
View CustomTileProvider.java
public class CustomTileProvider implements TileProvider {
public static final byte[] TRANSPARENT_TILE;
static {
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(256, 256, conf);
Canvas canvas = new Canvas(bmp);
canvas.drawColor(0);