Skip to content

Instantly share code, notes, and snippets.

View Kisty's full-sized avatar

Timothy Kist Kisty

View GitHub Profile
@okets
okets / gist:b2bdf3ba2ab96c27ad58274372298261
Last active January 8, 2024 00:10
figure out the room Valetudo robot is right now.
const mapData = msg.payload;
const _pixelSize = mapData.pixelSize;
let _robotXY = null;
for (let i = 0; i < mapData.entities.length; i++) {
if (mapData.entities[i].type == "robot_position") {
_robotXY = {
x: Math.floor(mapData.entities[i].points[0] / _pixelSize),
y: Math.floor(mapData.entities[i].points[1] / _pixelSize)
};
break;
@MakiseKurisu
MakiseKurisu / pimox.sh
Last active December 24, 2023 06:10
Install Pimox on Rock Pi 4B+
# You will need a real Debian machine to perform cross debootstrap
# Debian on WSL does not work
# Enter root mode
sudo -i
# Define variables
TARGET=/dev/mmcblk0
MOUNT_POINT=/mnt
IP_ADDRESS=192.168.0.2
@piratecarrot
piratecarrot / keepassxc-setup.sh
Last active October 2, 2023 10:45
Setting up KeePassXC with Google Drive synchronisation and SSH Agent
# This is intended to be copied and pasted to a console, not executed as a script... for now.
# Install some stuff, I use yay, you may use something else
sudo pacman -S keepassxc rclone curl
mkdir -p ~/.local/bin
mkdir -p ~/.local/lib/private
chmod 0700 ~/.local/lib/private
# CREATE YOUR KEEPASSXC BASE IN ~/.local/lib/private/
@longv
longv / LifecycleAwareLazy.kt
Created February 11, 2021 12:34
Lifecycle-aware Lazy
fun <T> LifecycleOwner.lifecycleAwareLazy(initializer: () -> T): Lazy<T> = LifecycleAwareLazy(this, initializer)
private object UninitializedValue
class LifecycleAwareLazy<out T>(
private val owner: LifecycleOwner,
initializer: () -> T
) : Lazy<T>, Serializable, LifecycleObserver {
private var initializer: (() -> T)? = initializer
import time
print "..."
time.sleep(1)
print "..."
print "..."
print "..."
print "..."
time.sleep(1)
print "..."
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@chrisbanes
chrisbanes / Animators.kt
Last active March 7, 2024 11:13
Material Image Loading treatment for Android
/*
* Copyright 2018 Google, Inc.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@JoseAlcerreca
JoseAlcerreca / EventObserver.kt
Created April 26, 2018 12:14
An Observer for Events, simplifying the pattern of checking if the Event's content has already been handled.
/**
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
* already been handled.
*
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
onEventUnhandledContent(value)

Facebook

Add your development and release key hashes To ensure the authenticity of the interactions between your app and Facebook, you need to supply us with the Android key hash for your development environment. If your app has already been published, you should add your release key hash too. You'll have a unique development key hash for each Android development environment. To generate a development key hash, on Mac, run the following command:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

On Windows, run this command:

@joseluisq
joseluisq / stash_dropped.md
Last active March 28, 2024 11:59
How to recover a dropped stash in Git?

How to recover a dropped stash in Git?

1. Find the stash commits

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

This will show you all the commits at the tips of your commit graph which are no longer referenced from any branch or tag – every lost commit, including every stash commit you’ve ever created, will be somewhere in that graph.