Skip to content

Instantly share code, notes, and snippets.

@ToxicBakery
ToxicBakery / CircularArray.kt
Last active February 27, 2024 00:46
Simple circular/ring buffer style implementation backed by an array for kotlin with test coverage
import java.util.concurrent.atomic.AtomicInteger
class CircularArray<T> : Iterable<T>, Cloneable {
/**
* Creates a new instance of the array with the given size.
*/
constructor(bufferSize: Int) {
this.arr = arrayOfNulls(bufferSize)
this.tail = -1
@wojteklu
wojteklu / clean_code.md
Last active April 26, 2024 05:52
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@tyvsmith
tyvsmith / dex-count.sh
Created July 22, 2013 18:45
"`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH." Use this to keep track of methods and fields in your apk. They are both limited to 65536. Example use: $ source dex-count.sh; $ dex-field-count classes.dex; Original method scrip…
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)