Skip to content

Instantly share code, notes, and snippets.

Avatar
🎨
painting boxes

Paco pakoito

🎨
painting boxes
View GitHub Profile
View starship.toml
add_newline = true
[character]
success_symbol = "[ƛ](bold green)"
error_symbol = "[ƛ](bold red)"
[git_branch]
format = ": [$symbol$branch]($style) } "
[java]
View ContextN.kt
inline fun <A, T> withN(t: T, f: context(T) () -> A) =
with(t) { f() }
inline fun <A, T, U> withN(t: T, u: U, f: context(T, U) () -> A) =
with(t) { with(u) { f() } }
inline fun <A, T, U, V> withN(t: T, u: U, v: V, f: context(T, U, V) () -> A) =
with(t) { with(u) { with(v) { f() } } }
inline fun <A, T, U, V, W> withN(t: T, u: U, v: V, w: W, f: context(T, U, V, W) () -> A) =
View gist:925dd5b488cd49a77c8de8a21206f58e
data class User(
val name: String
)
interface GetUserService {
fun Id.fetchUser(): User
}
context(Context)
fun makeGetUserService(): GetUserService = object : GetUserService {
@pakoito
pakoito / forge.cmd
Last active Jan 11, 2022
MTG Forge Windows Launcher
View forge.cmd
::@echo off
pushd %~dp0
java -version 1>nul 2>nul || (
echo no java installed
popd
exit /b 2
)
for /f tokens^=2^ delims^=.-_^+^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j"
View Extract pages from pdf
pdfx() {
name=$(basename $3 .pdf)
for i in {0..$(expr $(vipsheader -f pdf-n_pages $3) - 1)}; do
noglob vips copy $3[dpi=$1,page=$i] $(realpath $2)/$name-$(expr $i + 1)@$1.jpg;
done
}
# cmd dpi outdir infile
# pdfx 300 ./out mypdf.pdf
View gist:7802ab6a2389721519a1f0d6da691d31
private fun loggedInMenuUi(menu: Menu, rootView: View, checkoutCartStream: Stream<Bla>, startActivity: () -> Unit) {
val alertMenuItem = menu.findItem(R.id.activity_main_alerts_menu_item)
val rootView = (alertMenuItem.actionView as FrameLayout).apply {
setOnClickListener {
startActivity()
}
}
val redCircle: FrameLayout = rootView.findViewById(R.id.view_alert_red_circle)
View is there better way
when (info) {
null -> {
return unauthorized()
}
else -> {
val validInfo = validator.validateInfo(info)
when (validInfo) {
is Either.Right -> {
if (!validInfo.b.authorised) {
View comonads.js
const Day = ({ get, left, right }) => {
const map = f => Day ({
get: f (extract()),
left, right
})
const extend = f =>
Day ({
get: (left, right) => f (Day ({ get, left, right })),
@pakoito
pakoito / Test.kt
Created Apr 8, 2018
Applicatives, Functors and Monads using Kotlin and Arrow
View Test.kt
import arrow.core.*
import arrow.data.k
import arrow.syntax.applicative.tupled
import arrow.syntax.functor.map
import arrow.typeclasses.binding
typealias IntFunction = (Int) -> Int
fun IntFunction.map(g: IntFunction) = { it: Int -> this(g(it)) }