Skip to content

Instantly share code, notes, and snippets.

View KentVu's full-sized avatar

Kiên T Vu KentVu

View GitHub Profile
@Lighter955
Lighter955 / ExposedDropdownMenuBox.kt
Last active May 22, 2023 07:47
ExposedDropdownMenuBox for Compose Mutiplatform
package androidx.compose.material3
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.runtime.Composable
@Nezteb
Nezteb / atuin.zsh
Created May 5, 2023 00:57
A shell hack for restoring basic up/down arrow functionality with atuin while still using its database instead of vanilla shell history until it's implemented natively: https://github.com/ellie/atuin/issues/798
export ATUIN_ARROW_INDEX=-1
upArrow() {
export ATUIN_ARROW_INDEX=$(( ATUIN_ARROW_INDEX + 1))
COMMAND=$(atuin search --limit 1 --offset $ATUIN_ARROW_INDEX | cut -f2)
LBUFFER="$COMMAND"
return
}
@alexito4
alexito4 / Task.swift
Created October 12, 2022 21:21
SwiftUI View.task backwards compatibility
import Foundation
import SwiftUI
public extension View {
@available(iOS, obsoleted: 15.0, message: "SwiftUI.View.task is available on iOS 15.")
@_disfavoredOverload
@inlinable func task(
priority: _Concurrency.TaskPriority = .userInitiated,
@_inheritActorContext _ action: @escaping @Sendable () async -> Swift.Void
) -> some SwiftUI.View {
@bbqtd
bbqtd / macos-tmux-256color.md
Last active July 24, 2024 06:15
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

@gstraymond
gstraymond / Trie.kt
Created February 14, 2018 18:23
Kotlin Trie
package fr.gstraymond.search
data class Trie(private val char: Char,
private val indices: MutableList<Int> = mutableListOf(),
private val children: MutableList<Trie> = mutableListOf()) {
fun add(word: String,
index: Int) {
val first = word.first()
val trie = findOrCreate(first)
@magillus
magillus / LifecycleObservableTransformer.java
Last active March 29, 2018 05:54
Observable transformer that will act on event of the Lifecycle to auto dispose its subscriptions when the event occurs. By default ON_DESTROY
package com.example.playground;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
import android.support.annotation.NonNull;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.Map;
@CodyEngel
CodyEngel / DisposableManager.java
Created April 15, 2017 00:12
A singleton wrapper for managing a CompositeDisposable.
public class DisposableManager {
private static CompositeDisposable compositeDisposable;
public static void add(Disposable disposable) {
getCompositeDisposable().add(disposable);
}
public static void dispose() {
getCompositeDisposable().dispose();
@subfuzion
subfuzion / curl.md
Last active July 25, 2024 08:53
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@santa4nt
santa4nt / HelloJNI.java
Last active June 2, 2024 17:19
Sample JNI/C++ HelloWorld
public class HelloJNI {
static {
System.loadLibrary("hello"); // loads libhello.so
}
private native void sayHello(String name);
public static void main(String[] args) {
new HelloJNI().sayHello("Dave");
}
@JakeWharton
JakeWharton / dex.sh
Last active March 25, 2024 13:54
`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.
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)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')