Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
println("Kotlin is nice")

William Johnson S. Okano williamokano

🎯
println("Kotlin is nice")
View GitHub Profile
View git-find-me-the-fucking-deleted-file.sh
# If you don't remember the exact path/name, search the log for deleted files
git log --diff-filter=D --summary | grep delete
# Find the file you want to get from the ouput, and use the path
# Find the commits that involved that path
git log --all -- some/path/to/deleted.file
# Bring the file back to life to the current repo (sha commit of parent of commit that deleted)
g co shaofthecommitthatdeletedthefile^ -- some/path/to/deleted.file
@williamokano
williamokano / .zshrc
Created Sep 10, 2020 — forked from ThYpHo0n/.zshrc
WSL(2) bash profile helpers
View .zshrc
# Windows XSrv config
export $(dbus-launch)
export LIBGL_ALWAYS_INDIRECT=1
export WSL_VERSION=$(wsl.exe -l -v | grep -a '[*]' | sed 's/[^0-9]*//g')
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
export DISPLAY=$WSL_HOST:0
@williamokano
williamokano / .zshrc
Created Sep 10, 2020 — forked from ThYpHo0n/.zshrc
WSL(2) bash profile helpers
View .zshrc
# Windows XSrv config
export $(dbus-launch)
export LIBGL_ALWAYS_INDIRECT=1
export WSL_VERSION=$(wsl.exe -l -v | grep -a '[*]' | sed 's/[^0-9]*//g')
export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
export DISPLAY=$WSL_HOST:0
@williamokano
williamokano / README.md
Created May 7, 2020 — forked from Brunomachadob/README.md
Educational purposed implementation of a Onion Router (specification of Tor)
View README.md

This is a educational purposed implementation of the Onion Router specification for encrypted/annonymous conversation between two parties.

Do not use this in production (as it is simplifying a lot of stuff, despite I know you will ignore this)

If you use IntelliJ, you can just paste the implementation into a new scratch and run it.

Let me know in the comments if you have anything that could be improved (without adding too much complexity to it)

@williamokano
williamokano / README.md
Created May 7, 2020 — forked from Brunomachadob/README.md
Educational-purposed implementation of Diffie Hellman key exchange
View README.md

This is a educational purposed implementation of the Diffie Hellman key exchange for encrypted conversation between two parties.

Do not use this in production (as it is simplifying a lot of stuff, despite I know you will ignore this)

If you use IntelliJ, you can just paste the implementation into a new scratch and run it.

@williamokano
williamokano / sample_dsl.kt
Created May 1, 2020
Sample DSL example - Just playing around
View sample_dsl.kt
package dev.okano.kotlin.coroutines.mains
data class Header(val name: String, val value: String)
data class HeaderBuilderDsl(val context: Request) {
companion object {
fun withContext(context: Request): HeaderBuilderDsl {
return HeaderBuilderDsl(context)
}
}
@williamokano
williamokano / sample_dsl.kt
Created May 1, 2020
Sample DSL example - Just playing around
View sample_dsl.kt
package dev.okano.kotlin.coroutines.mains
data class Header(val name: String, val value: String)
data class HeaderBuilderDsl(val context: Request) {
companion object {
fun withContext(context: Request): HeaderBuilderDsl {
return HeaderBuilderDsl(context)
}
}
@williamokano
williamokano / kinesis-get-records.sh
Created Mar 23, 2020 — forked from codemedic/kinesis-get-records.sh
Get records from a AWS Kinesis Data Stream. It allows you to start iterating from a time in the past.
View kinesis-get-records.sh
#!/usr/bin/env bash
if ! aws_bin="$(which aws)" 2>/dev/null; then
echo "aws cli is missing; you can get it from https://aws.amazon.com/cli/"
exit 1
fi
if ! jq_bin="$(which jq)" 2>/dev/null; then
echo "jq is missing; you can get it from https://stedolan.github.io/jq/"
exit 1
@williamokano
williamokano / Main.kt
Created Jan 3, 2020
Simple logger "wrapper" to create loggers and remove the boiler plate of LoggerFactory
View Main.kt
fun <T : Any> T.logger(): Logger =
LoggerFactory.getLogger(this::class.java.name.substringBefore("\$Companion"))
class XPTO {
fun info(message: String) {
logger.info(message)
}
companion object {
private val logger = logger()
View kotlin_weird_stuff.kt
import java.util.*
infix fun <R> (() -> R).times(times: Int): List<R> = times.takeIf { it > 0 }
?.let { (1..it) }
?.map { this() }
?: emptyList()
inline infix operator fun <R> Int.times(block: () -> R): List<R> = this.takeIf { it > 0 }
?.let { (1..this) }
?.map { block() }