Skip to content

Instantly share code, notes, and snippets.

View neogeogre's full-sized avatar
:electron:
Still alive

Geoffrey Vincent neogeogre

:electron:
Still alive
View GitHub Profile
@neogeogre
neogeogre / coroutineMultiJobs.kt
Created October 18, 2023 09:52
trigger and stop multiple // jobs with kotlin coroutine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
fun main() {
val jobs = List(5) {
val job = CoroutineScope(Dispatchers.Default).launch {
delay(2000)
println("Work $it is done")
@neogeogre
neogeogre / build.gradle.kts
Last active August 25, 2023 11:12
add and display gradle kotlin dsl tasks
tasks.register("before") {
doLast {
val myVar = "Hello variable"
println(myVar)
}
}
tasks.register("after") {
doLast {
println("Hello, 2!")
@neogeogre
neogeogre / mysql_dump_docker.sh
Last active March 8, 2023 17:32
run pg_dump from docker image
docker run -it \
--user $(id -u):$(id -g) \
-v ~/Desktop:/tmp \
mysql:5.7.37 /bin/bash -c \
"mysqldump -h hostname -u username -p databasename table1 table2 --port 3306 > /tmp/dumpfile.sql"
# https://stackoverflow.com/questions/44015692/access-denied-you-need-at-least-one-of-the-super-privileges-for-this-operat
grep -n @@SESSION. myDB.sql
sed -i '18d' myDB.sql
@neogeogre
neogeogre / git-revert.sh
Last active April 15, 2023 15:01
revert HEAD to a certain commit point using git commands
# https://stackoverflow.com/questions/3380805/checkout-old-commit-and-make-it-a-new-commit
# https://gist.github.com/CrookedNumber/8964442?permalink_comment_id=3426850#gistcomment-3426850
git reset --hard 0fee5ad9
git push origin -f
# https://stackoverflow.com/questions/7744049/git-how-to-rebase-to-a-specific-commit
git rebase --onto <new parent commit hash> <old parent commit hash>
@neogeogre
neogeogre / bulk-edit-git-repos.kt
Created August 18, 2022 08:26
Edit plenty of git repos at once
import java.io.File
import java.lang.ProcessBuilder.Redirect.INHERIT
import java.nio.file.Files
import java.util.concurrent.TimeUnit.MINUTES
import kotlin.io.path.Path
const val ROOT = "/home/geoffrey/Desktop/gitlab"
fun main() = Files
.walk(Path(ROOT), 1)
@neogeogre
neogeogre / encryption.kt
Created July 21, 2022 10:30
simplest way to have cipher encryption in Kotlin
import java.util.*
import javax.crypto.Cipher.*
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
fun main() {
val str = "Hello World !"
val encryptionKey = "1mfNnQ8CSdxHOhwO"
println(str)
val encoded = encrypt(str, encryptionKey)
@neogeogre
neogeogre / .bashrc
Created January 8, 2022 20:57
pyenv paths
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
@neogeogre
neogeogre / docker-compose-postgis.yml
Last active February 16, 2023 16:21
Generate a postgis container
version: '3.7'
services:
postgis:
image: postgis/postgis:12-3.1
restart: always
environment:
- POSTGRES_USER=demo
- POSTGRES_PASSWORD=demo
- POSTGRES_DB=demo
ports:
@neogeogre
neogeogre / windows-image-viewer.reg
Last active December 7, 2021 10:28
restore windows image viewer
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll]
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell]
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open]
"MuiVerb"="@photoviewer.dll,-3043"
[HKEY_CLASSES_ROOT\Applications\photoviewer.dll\shell\open\command]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,72,00,75,00,\
6e,00,64,00,6c,00,6c,00,33,00,32,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,\
00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,46,00,69,00,6c,00,65,00,73,00,\
@neogeogre
neogeogre / superUser.sh
Last active January 23, 2023 14:11
linux commands
sudo chown -R $(id -u):$(id -g) ~/Desktop/
sudo chown -R $USER:$USER .
sudo chmod a+rwx myFile.sh
# 10 biggest files
du -a -h /path | sort -h -r | head -n 10
ls -1Rhs | sed -e "s/^ *//" | grep "^[0-9]" | sort -hr | head -n20
# See which PID/service is using a certain IP and port:
sudo netstat -nlpt |grep 3306