Skip to content

Instantly share code, notes, and snippets.

View williamokano's full-sized avatar
🎯
println("Kotlin is nice")

William Okano williamokano

🎯
println("Kotlin is nice")
View GitHub Profile
@williamokano
williamokano / git-find-me-the-fucking-deleted-file.sh
Created April 14, 2021 10:58 — forked from joakin/git-find-me-the-fucking-deleted-file.sh
finding a deleted file in a git repository
# 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 September 10, 2020 03:38 — forked from ThYpHo0n/.zshrc
WSL(2) bash profile helpers
# 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 September 10, 2020 03:38 — forked from ThYpHo0n/.zshrc
WSL(2) bash profile helpers
# 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 23:52 — forked from Brunomachadob/README.md
Educational purposed implementation of a Onion Router (specification of Tor)

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 23:50 — forked from Brunomachadob/README.md
Educational-purposed implementation of Diffie Hellman key exchange

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 08:52
Sample DSL example - Just playing around
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 08:52
Sample DSL example - Just playing around
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 March 23, 2020 18:15 — 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.
#!/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 January 3, 2020 15:29
Simple logger "wrapper" to create loggers and remove the boiler plate of LoggerFactory
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()
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() }