Skip to content

Instantly share code, notes, and snippets.

View bqm's full-sized avatar
🧙

bqm

🧙
View GitHub Profile
@bqm
bqm / SavedModelGitHubIssue28195.pbtxt
Last active September 30, 2019 16:08
`SavedModel` object stored as a protobuf text format. The code for creating this object is available at https://github.com/tensorflow/tensorflow/issues/28195.
saved_model_schema_version: 1
meta_graphs {
meta_info_def {
stripped_op_list {
op {
name: "Const"
output_arg {
name: "output"
type_attr: "dtype"
}
@bqm
bqm / MonoidFromMonad.md
Last active May 14, 2016 16:45
If M is a Monad then for any A, the set of `A => M[A]` forms a monoid

Claim: If M is a Monad, then for any type A, the set of A => M[A] forms a monoid

Reminder

  • A monad can defined:
trait Monad[M[_]] {
  def pure[A](a: A): M[A]
 def flatMap[A](m: M[A])(f: A => M[B]): M[B]
import cats.{Id, Functor, Monad, ~>}
import cats.std.function._
import cats.syntax.cartesian._
sealed trait KVS[A]
case class Put[A](key: String, value: String, a: A) extends KVS[A]
case class Get[A](key: String, a: String => A) extends KVS[A]
type Dsl[A] = ApFree[KVS, A]
@bqm
bqm / ApFree.scala
Last active May 2, 2016 18:28
Naive implementation of an hybrid free monad / free applicative
import cats._
import cats.free._
import cats.arrow.NaturalTransformation
object ApFree {
/**
* Return from the computation with the given value.
*/
private final case class Pure[S[_], A](a: A) extends ApFree[S, A]
@bqm
bqm / findMeetupWaitlistPosition.js
Last active April 6, 2023 15:40
Find your position in a meetup.com waitlist
// Open the developer console of your favorite browser
// on the page of your favorite meetup where you're on the wailist (grrr)
// and paste this by putting your name
// This will actually compute the position in the waitlist div which seems to correspond to the waitlist position
var findPosition = function(username) { return $("#rsvp-list-waitlist h5").map(function(i, el) {return {"pos": i, "name": $(el).text()}}).filter(function(i, el) {return el["name"].indexOf(username) >= 0;})}
findPosition("my displayed name") // where my displayed name is the name that is displayed for you on the meetup