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 / 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 / .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 / 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 / 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 / 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 / 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 / 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 / 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")