Skip to content

Instantly share code, notes, and snippets.


Przemek Pokrywka przemek-pokrywka

View GitHub Profile
przemek-pokrywka / example.scala
Last active Nov 14, 2021
Can programming be liberated from the ZIO layer style?
View example.scala
/// Powered by TSK - The Scripting Kit 2> /dev/null \\\
export v=0.1.5
. $(b=boot-tsk-$v$b; (cat ~/.tsk/$b || curl -sfL $u || wget -qO - $u) | sh)
przemek-pokrywka / MagicImportsAreNotValid.scala
Created Oct 22, 2021
The Ammonite magic imports are (unfortunately!) NOT a valid Scala 😞 - the issue is that the dots within the version numbers are breaking compilation, even if you use the backticks
View MagicImportsAreNotValid.scala
package $ivy
object `group::artifact:1` {
object `2` {
object `3` {
val exception = new Exception()
import $ivy.`group::artifact:1`.`2`.`3`.exception._
View git-gone
usage() {
cat <<EOF
usage: git gone [-pldD] [<branch>=origin]
-p prune remote branch
-n dry run: list the gone branches
-d delete the gone branches
-D delete the gone branches forcefully

Keybase proof

I hereby claim:

  • I am przemek-pokrywka on github.
  • I am przemekpokrywka ( on keybase.
  • I have a public key ASBg_m-i2q5d06b9QdXWtWhLsVNydC_o6hwc83t6YpsPIgo

To claim this, I am signing this object:

przemek-pokrywka / scraper.scala
Created Sep 4, 2016
The example shown at Scalapolis 2016 in Wrocław (with small improvements). HTML scraping of the conference page done as a one-file executable Scala script.
View scraper.scala
trait valid_both_in_bash_and_in_scala /* 2>/dev/null
# ^^^ can be replaced by anything that's harmless in Bash and valid top-file-def in Scala.
# Kudos to that attendee (sorry, I don't know your name), who noticed that opportunity. Cheers!
# Making sure Coursier is available
test -e $cr/cr || (mkdir $cr && wget -q -O $cr/cr && chmod +x $cr/cr)
przemek-pokrywka /
Last active May 7, 2016
Serve a webpage using Play framework with a simple script. Nothing more, than Linux and Java required. Thanks to brilliant work of Alexandre Archambault, @li_haoyi and Play developers.
test -e ~/.coursier/cr || (mkdir -p ~/.coursier && wget -q -O ~/.coursier/cr && chmod +x ~/.coursier/cr)
CLASSPATH="$(~/.coursier/cr fetch -q -p \
\ \ \
com.lihaoyi:ammonite-repl_2.11.7:0.5.2 \
)" java \ \
przemek-pokrywka / Scala-style underscore in
Last active Sep 20, 2015
I've stumbled upon wonderful library. One thing I missed was the ability to use `_.method(args)` syntax. Following quick hack aims to fix that. CAVEAT: it's a hack, it'll work unpredictably for cases different than `_.method(args)`.
View Scala-style underscore in
class Underscore:
def __getattr__(self, methodname):
return lambda *args, **kwargs: \
lambda o: eval("o." + methodname)(*args, **kwargs)
_ = Underscore()
filter(_.startswith("A"), ["Africa", "America", "Europe"])
map(_.upper(), ["hello", "world"])
map(_.count("I"), ["TEAM", "TIM"])
przemek-pokrywka / gist:9315172
Created Mar 2, 2014
How to get None when reduction was not applied and Some(value) when it did in scala.rx
View gist:9315172
package frp
import rx._
import rx.ops._
object Demo extends App {
case class Val[+T](value: T, reduced: Boolean = false) {
def toOpt = if (reduced) Some(value) else None
przemek-pokrywka / StackTraceHelper.scala
Created Sep 19, 2013
Small utility to clean up longish stacktraces. All comments how to make it more generic warmly welcome.
View StackTraceHelper.scala
object StackTraceHelper
def retainWithBorder [T] (items: Seq[T],
valuable: (T => Boolean)): Seq[T] =
if (items.size < 3) return items
val retained = for