Skip to content

Instantly share code, notes, and snippets.

View michbarsinai's full-sized avatar
😵
Happily overworked

Michael michbarsinai

😵
Happily overworked
View GitHub Profile
@michbarsinai
michbarsinai / UriBase64Long.scala
Created November 9, 2021 21:04
Present a 64-bit long Int in a URI-safe Base 64 encoding, in scala
/*
Usage:
> UriBase64Long(1234567891011L).mkString
val res41: String = dqTp5Kaa
> Range(0,8).map(_=>Random.nextLong()).flatMap(UriBase64Long(_)).mkString
val res42: String = 6MO_7T1drnVveBdcHYG08PcCDyx5QlyU@~T8UpTr6Go02cjd7@IJBYSHk0EttfhS
*/
@michbarsinai
michbarsinai / FileSorter.scala
Created August 12, 2020 08:52
A simple Scala script to group files by month.
import java.nio.file._
import java.nio.file.attribute._
import scala.collection.JavaConverters._
import java.time._
import java.time.format._
val fmt = DateTimeFormatter.ofPattern("yyyy-MM")
val src = Paths.get(args(0))
val dst = Paths.get(args(1))
@michbarsinai
michbarsinai / scala
Created October 27, 2017 13:03
Twirl/Play mini function for presenting a HTML fragment for non-null, non-empty strings
def nonEmpty( v:String )(f:(String=>Html)):Html = {
if ( v != null && v.trim.nonEmpty ) {
f(v.trim)
} else {
Html("")
}
}
@michbarsinai
michbarsinai / README.md
Last active December 24, 2015 00:09 — forked from thedod/README.md

Israeli? Support #No2Bio? Got some time?

We now have an open knesset embed showing the history of the biometric database bill, and if you click on the "3" (third vote) - you can see who voted for and against our privacy.

I'd rather not count on people "clicking on the 3". I want users to look these MKs in the eye and memorize who exactly didn't give a damn about their basic human rights. Is it too much to ask? :)

I've asked whether there was a way to make the embed open a specific popup, and @daonb suggested getting the information via API (thanks), so I took this JSON, imported the MK information into the vote objects (no need to fetch any URLs. All data's in there), and trimmed some fluff we probably wouldn't use (committee membership, etc.).

As an example - index.html shows on a map where the MKs who voted against our privacy live.

@michbarsinai
michbarsinai / gist:4148977
Created November 26, 2012 16:05
Start a mail with an attachment from terminal, in OSX
open -a Mail <path-to-file>