Skip to content

Instantly share code, notes, and snippets.

@nsanch
nsanch / party.sh
Last active March 9, 2017 19:35 — forked from benlanier/party.sh
shoddy party-fier
#!/bin/sh
#
# Create a rotating, hue-cycling figure using Distort SRT transformations
#
# Usage: INPUT_FILENAME=Downloads/turkey_5feec0.png OUTPUT_FILENAME=party_turkey.gif party.sh
set -xeo pipefail
command="convert -dispose previous -delay 3 $INPUT_FILENAME -virtual-pixel Transparent -scale 120%"
sealed abstract class NumberOfCopies[Next <: NumberOfCopies](next: Next) { type PlusOne = Next }
case object NoCopies extends NumberOfCopies(OneCopy)
case object OneCopies extends NumberOfCopies(TwoCopies)
case object TwoCopies extends NumberOfCopies(ThreeCopies)
case object ThreeCopies extends NumberOfCopies(FourCopies)
case object FourCopies extends NumberOfCopies(FiveOrMoreCopies)
case object FiveOrMoreCopies extends NumberOfCopies(FiveOrMoreCopies)
abstract class FSCountingSeq[T, TotalNumberOfCopies <: NumberOfCopies](underlying: Seq[T], totalCopies: TotalNumberOfCopies) = {
def map[U](f: T => U): FSCountingSeq[U, TotalNumberOfCopies#PlusOne] = FSCountingSeq(underlying.map(f), totalCopies.next)
@nsanch
nsanch / gist:dabc1f221596694a7d0e
Created August 22, 2014 15:12
val in trait calls def, hilarity ensues
object ValInTraitCallsDef {
trait T {
def x: Int
val y = x
}
class OverridesWithVal extends T {
override val x = 1
}
def multiply(a: Int, b: Int) = a * b
scala> implicit class FSFunction2[In1, In2, Out](val f: Function2[In1, In2, Out]) extends AnyVal {
def andThen[Out2](f2: Function1[Out, Out2]): Function2[In1, In2, Out2] = (x: In1, y: In2) => f2(f(x, y))
}
scala> (multiply _ andThen identity _)(2, 3)
res5: Int = 6
import org.apache.thrift._
import org.apache.thrift.protocol._
import com.foursquare.base.gen._
import com.foursquare.common.thrift._
import com.foursquare.common.thrift.bson._
import com.foursquare.common.thrift.json._
def roundtrip(writeProt: TProtocolFactory, readProt: TProtocolFactory) {
val longconv = new ThriftConverter[LongWrapper](readProt)
val stringconv = new ThriftConverter[StringWrapper](writeProt)

Keybase proof

I hereby claim:

  • I am nsanch on github.
  • I am nsanch (https://keybase.io/nsanch) on keybase.
  • I have a public key whose fingerprint is CBA1 6DD0 FDEE 0DFD 995B F8B4 D165 8EA4 11D2 2962

To claim this, I am signing this object:

@nsanch
nsanch / enriched
Last active August 29, 2015 13:56
idea for enriching thrift records without using proxy objects
// Sample usage:
val v: ThriftVenueModel = ...
val ev = EnrichedVenue = v.enrich(EnrichedVenue)
if (ev.isHomeOrPrivate) {
...
}
// These are base classes like Enum and EnumMeta that never appear in codegen.
ear Timehopper,
You're receiving this email because you're subscribed to Timehop's daily email service that tells you what you did 1 year ago today on Facebook, Twitter, Foursquare, etc.
We wanted to let you know about an important change. We're sunsetting the Timehop daily email and pulling all our efforts behind the Timehop mobile app. We appreciate your support and hope you'll understand that as a small startup we have to pick our battles carefully.
We'll stop sending the daily Timehop emails in 5 days: Wednesday July 17th.
If you have an iPhone/iPod/iPad? Get our app: timehop.com/iphone
If you have an Android or another phone, we don't currently have an app for you but hopefully we'll get there in the future. If you'd like to help us with this, we're hiring -- get in touch!