Skip to content

Instantly share code, notes, and snippets.

View LDuncAndroid's full-sized avatar

L Duncan LDuncAndroid

  • Highlands, Scotland
  • 13:01 (UTC +01:00)
View GitHub Profile
@LDuncAndroid
LDuncAndroid / iterable_sequence_count_pairs.kts
Last active May 24, 2021 22:23
Counts Pairs in Iterable & Sequence
fun <T> Iterable<T>.countPairs() = groupingBy { it }
.eachCount()
.values
.sumOf { it.div(2) }
fun <T> Sequence<T>.countPairs() = groupBy { it }
.mapValues { it.value.size }
.values
.sumOf {it.div(2)}
#!/bin/bash
FGCOLOR='f5f4f0'
BGCOLOR='555555'
BG_ALPHA='51'
max_len=50
Clock() {
#TIME=$(date "+%S seconds past %H%M")
TIME=$(date "+%H%M+%S")
@latant
latant / rmi-example.kt
Created March 9, 2020 22:59
An example using Java RMI with Kotlin
import java.io.Serializable
import java.rmi.Remote
import java.rmi.RemoteException
import java.rmi.registry.LocateRegistry
import java.rmi.server.UnicastRemoteObject
class Person(val name: String, val age: Int): Serializable
interface HelloService : Remote {
@Throws(RemoteException::class)
@faruktoptas
faruktoptas / debounce.kt
Created March 5, 2020 06:28
Kotlin coroutine debounce for EditText
fun <T> debounce(
waitMs: Long = 300L,
scope: CoroutineScope,
destinationFunction: (T) -> Unit
): (T) -> Unit {
var debounceJob: Job? = null
return { param: T ->
debounceJob?.cancel()
debounceJob = scope.launch {
delay(waitMs)
1. Add dependecy:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
2.Create config file for log4j (https://logging.apache.org/log4j/2.x/manual/configuration.html).
I prefer log4j2-test.properties because according documentation this format will look second, after configFile:
'If no system property is set the properties ConfigurationFactory will look for log4j2-test.properties in the classpath.'
---------------------------------------------------------------
[
{
"title":"Lemon cheesecake",
"desc":"A cheesecake made of lemon",
"image":"https://s3-eu-west-1.amazonaws.com/s3.mediafileserver.co.uk/carnation/WebFiles/RecipeImages/lemoncheesecake_lg.jpg"
},
{
"title":"victoria sponge",
"desc":"sponge with jam",
"image":"https://upload.wikimedia.org/wikipedia/commons/0/05/111rfyh.jpg"
@ptkdev
ptkdev / android-restore-password-keystore-jks.md
Last active March 28, 2023 15:51
Android: Recovery lost keystore jks file or keystore password

Sign android app with new keystore file if you missing password or lost jks file.

  1. Create new keystore.jks file with comand line (not android studio build menu)

    Linux: keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks

    Windows: "C:\Program Files\Android\Android Studio\jre\bin\keytool.exe" -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore "C:\keystore_new.jks"

  2. Generate a .pem file from new keystore

# Connectiong by SSH from Android Termux to Desktop and vice-versa.md
# Copyright (c) 2019 Evandro Coan
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
@venkai
venkai / Ubuntu 18.04 with Nvidia+CUDA on Optimus Laptop.md
Created July 16, 2018 18:51 — forked from hemenkapadia/Ubuntu 18.04 with Nvidia+CUDA on Optimus Laptop.md
[Ubuntu 18.04 with Nvidia+CUDA on Optimus Laptop] Setting up Ubuntu 18.04 with nvidia drivers and CUDA for data science on Dell 7559 Optimus laptop #Ubuntu #Nvidia #CUDA #setup

Kernel settings for installation

Use a live usb to try Ubuntu before installing. Boot from the live usb. On the GRUB screen highlight the "Try Ubuntu ...." option and press e. Update kernel parameters by adding options before quiet splash such that the line should read as below

nogpumanager nomodeset i915.modeset=1 quiet splash

Note: On HighDPI screen machines there is a known issue whereby Ubiquity (ubuntu installer) craashes at the copying files step i.e. immediatly after the user setup screen. The cause and workaround are discussed in other gist post

Persist GRUB configuration

Post installation, to avoid updating the above mentioned kernel options each time the system is booted, edit GRUB configuration file sudo vi /etc/default/grub and make th

@ernestkamara
ernestkamara / AdbCommands
Created June 26, 2018 08:42 — forked from Pulimet/AdbCommands
Adb useful commands list
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
== Shell