Skip to content

Instantly share code, notes, and snippets.

View alxrm's full-sized avatar
🤷‍♀️
I don't know jack

Alexey Derbyshev alxrm

🤷‍♀️
I don't know jack
View GitHub Profile
@alxrm
alxrm / delete_dotfiles.sh
Last active October 9, 2019 22:23
Simple bash script to delete all dot files in a given directory (not recursive)
#!/usr/bin/env bash
if ([ -z "$1" ]); then
echo "
Usage:
sh delete_dotfiles.sh /path/to/your/directory
";
exit 1;
fi
@alxrm
alxrm / factorize.kt
Created June 24, 2019 07:55
Recursive number factorisation in Kotlin
fun Long.factorizeRec(factor: Int = 2): IntArray = when {
this <= 1 -> intArrayOf()
this % factor == 0L -> intArrayOf(factor) + (this / factor).factorizeRec(factor)
else -> factorizeRec(if (factor == 2) 3 else factor + 2)
}
package com.moonlab.unfold;
import android.support.annotation.NonNull;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
import java.util.Objects;
@alxrm
alxrm / upwork-signer.sh
Last active November 21, 2019 09:52
Simple util I use to sign invoices only for Mac. You must have imagemagick installed
#!/usr/bin/env bash
if ([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]); then
echo "
Usage:
sh ./path/to/pdf-invoices ./path/to/signature.png ./output
Note:
Please mind the leading slashes, there should not be any!
";
@alxrm
alxrm / autotranslate.py
Last active January 30, 2019 20:57
Simple tool to apply translation mapping from iOS .strings file to Android strings.xml
import sys
import re
from functools import reduce
def lines_of(file_name):
with open(file_name) as f:
content = f.readlines()
return [x.rstrip() for x in content]
@alxrm
alxrm / find_dirs.sh
Last active December 16, 2018 09:51
Finds all of the directories you can safely delete for a specific name
#!/usr/bin/env bash
find ~/Library -type d -name "*$1*" -print 2>/dev/null
@alxrm
alxrm / pull.sh
Created December 2, 2018 20:35
Pulls database file from the connected Android device
#!/usr/bin/env bash
([ -z "$1" ] || [ -z "$2" ]) && echo "Usage:\n sh ./pull.sh com.package.name databaseName.db"
adb shell "run-as $1 chmod 666 /data/data/$1/databases/$2"
adb exec-out run-as "$1" cat databases/"$2" > ~/"$2"
adb shell "run-as $1 chmod 600 /data/data/$1/databases/$2"
echo "Done, go check ~/$2"
import java.util.*
fun main(args: Array<String>) {
val sc = Scanner(System.`in`)
val line = sc.nextLine()
val arr = line.map { it.toInt() }.toIntArray()
val n = arr.size
var a = 0
var count = 0
import java.util.*
fun main(args: Array<String>) {
val sc = Scanner(System.`in`)
val n = sc.nextInt()
val k = sc.nextInt()
val temperatures = IntArray(n)
for (i in 0 until n) {
val x = sc.nextInt()
interface DisjointSetUnion {
fun makeSet(node: String)
fun findSet(node: String): String
fun unionSets(left: String, right: String)
}