Required tools for playing around with memory:
hexdump
objdump
readelf
xxd
gcore
/** | |
* Fade a view to visible or gone. This function is idempotent - it can be called over and over again with the same | |
* value without affecting an in-progress animation. | |
*/ | |
fun View.fadeTo(visible: Boolean, duration: Long = 500, startDelay: Long = 0, toAlpha: Float = 1f) { | |
// Make this idempotent. | |
val tagKey = "fadeTo".hashCode() | |
if (visible == isVisible && animation == null && getTag(tagKey) == null) return | |
if (getTag(tagKey) == visible) return |
/* Copyright 2019 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* https://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, |
private var verticalScrollOffset = AtomicInteger(0) | |
recyclerView.addOnLayoutChangeListener { _, _, _, _, bottom, _, _, _, oldBottom -> | |
val y = oldBottom - bottom | |
if (y.absoluteValue > 0) { | |
recyclerView.post { | |
if (y > 0 || verticalScrollOffset.get().absoluteValue >= y.absoluteValue) { | |
recyclerView.scrollBy(0, y) | |
} else { | |
recyclerView.scrollBy(0, verticalScrollOffset.get()) |
import java.io.ByteArrayOutputStream | |
import java.io.File | |
import java.nio.charset.StandardCharsets.UTF_8 | |
import java.util.zip.GZIPInputStream | |
import java.util.zip.GZIPOutputStream | |
fun gzip(content: String): ByteArray { | |
val bos = ByteArrayOutputStream() | |
GZIPOutputStream(bos).bufferedWriter(UTF_8).use { it.write(content) } | |
return bos.toByteArray() |
#!/usr/bin/env python3 | |
""" | |
License: MIT License | |
Copyright (c) 2023 Miel Donkers | |
Very simple HTTP server in python for logging requests | |
Usage:: | |
./server.py [<port>] | |
""" | |
from http.server import BaseHTTPRequestHandler, HTTPServer |
int doubler(int x) { | |
return 2 * x; | |
} |
I’ve been struggling for some hours with TextView and Spannable.. ClickableSpan to be precise. It seems that when you tap the clickable text it gets an ugly orange stroke (might differ on devices) around the text and if you so happen to have this in a custom view as an item in e.g Gallery it really stands out by highlighting it everytime you scroll away from that view. Annoying, yes? | |
The solution is extremely simple and was provided by a thread over at Stackoverflow.com. | |
To edit or remove the higlight color you can simply set the TextViews highlight color itself to any color you want or Color.TRANSPARENT if you don’t want any color. | |
android:textColorHighlight="@color/something" | |
or in code | |
textView.setHighlightColor(Color.TRANSPARENT); |
# In the name of GOD the most compassionate the most merciful | |
# Originally developed by Yasse Souri | |
# Just added the search for current directory so that users dont have to use command prompts anymore! | |
# and also shows the top 4 accuracies achieved so far, and displaying the highest in the plot title | |
# Coded By: Seyyed Hossein Hasan Pour ([email protected]) | |
# -------How to Use --------------- | |
# 1.Just place your caffe's traning/test log file (with .log extension) next to this script | |
# and then run the script.If you have multiple logs placed next to the script, it will plot all of them | |
# you may also copy this script to your working directory, where you generate/keep your train/test logs | |
# and easily execute the script and see the curve plotted. |
import android.annotation.TargetApi; | |
import android.content.ContentUris; | |
import android.content.Context; | |
import android.database.Cursor; | |
import android.net.Uri; | |
import android.os.Build; | |
import android.os.Environment; | |
import android.provider.DocumentsContract; | |
import android.provider.MediaStore; | |
import android.provider.OpenableColumns; |