Skip to content

Instantly share code, notes, and snippets.

View pedrofurla's full-sized avatar

Pedro Furlanetto pedrofurla

View GitHub Profile
@i-am-tom
i-am-tom / Json.purs
Last active November 25, 2024 11:14
Parsing, Generating, and Diffing JSON in PureScript
module Main where
-- | JSON is an incredibly simple format. Even its lists are untyped.
-- | As with all languages, functional programming encourages us to
-- | make a domain-specific language (or DSL) to capture the "ideas"
-- | of the language, which we can then use to talk about its content.
-- | In this little snippet, we'll build a JSON DSL, transform it into
-- | a recursive structure, and then use that result to generate some
data EqBy a = EqBy (a -> Bool) a
instance Eq (EqBy a) where
EqBy f _ == EqBy _ y = f y
eqBy :: (a -> a -> Bool) -> a -> EqBy a
eqBy f x = EqBy (f x) x
equalBy :: (a -> a -> Bool) -> [a] -> [a] -> Bool
equalBy f xs ys = fmap (eqBy f) xs == fmap (eqBy f) ys
@paulp
paulp / build.sbt
Last active October 28, 2017 13:02
/** Your task is to reason your way to which compiler
* options which will be passed for each of
* 1) sbt root/compile
* 2) sbt p1/compile
*/
scalacOptions := Seq("-DSBT")
scalacOptions in ThisBuild += "-D0"
scalacOptions in Global += "-D1"

Code of Conduct

Communication

Times
  • All times will be communicated in a way that is unambiguous. This communication may be a local time, with a UTC offset specified.

For example:

@jhaberstro
jhaberstro / gpu_arch_resources
Last active December 10, 2024 11:12
GPU Architecture Learning Resources
http://courses.cms.caltech.edu/cs179/
http://www.amd.com/Documents/GCN_Architecture_whitepaper.pdf
https://community.arm.com/graphics/b/blog
http://cdn.imgtec.com/sdk-documentation/PowerVR+Hardware.Architecture+Overview+for+Developers.pdf
http://cdn.imgtec.com/sdk-documentation/PowerVR+Series5.Architecture+Guide+for+Developers.pdf
https://www.imgtec.com/blog/a-look-at-the-powervr-graphics-architecture-tile-based-rendering/
https://www.imgtec.com/blog/the-dr-in-tbdr-deferred-rendering-in-rogue/
http://developer.amd.com/tools-and-sdks/opencl-zone/amd-accelerated-parallel-processing-app-sdk/opencl-optimization-guide/#50401334_pgfId-412605
https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/
https://community.arm.com/graphics/b/documents/posts/moving-mobile-graphics#siggraph2015
@pedrofurla
pedrofurla / git-branches-by-commit-date.sh
Created November 4, 2016 18:59 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@jdegoes
jdegoes / IO.scala
Created August 9, 2016 22:26
A pedagogical implementation of the IO monad in Scala in 14 LOC
case class IO[A](unsafePerformIO: () => A) {
def map[B](ab: A => B): IO[B] = IO(() => ab(unsafePerformIO()))
def flatMap[B](afb: A => IO[B]): IO[B] =IO(() => afb(unsafePerformIO()).unsafePerformIO())
def tryIO(ta: Throwable => A): IO[A] =
IO(() => IO.tryIO(unsafePerformIO()).unsafePerformIO() match {
case Left(t) => ta(t)
case Right(a) => a
})
}
object IO {
@pedrofurla
pedrofurla / Tmp.scala
Last active June 11, 2016 15:06
Where String#+ comes from?
object Tmp {
"zzz" ++ "kkk" // Fails with -Yno-predef
// after typer the above is scala.this.Predef.augmentString("zzz").++[Char, String](scala.this.Predef.augmentString("kkk"))(scala.this.Predef.StringCanBuildFrom);
"aaa"+new Object() // Doesn't fail ever!
// after typer the above is "aaa".+(new java.this.lang.Object());
// Why didn't `+` desugar to something else?
new Object() + "aaa" // Fails with -Yno-predef
@jnape
jnape / TypeUnifailcation.java
Last active March 12, 2016 06:16
Java8 invokeinterface type-unification bug
package example;
import java.util.Optional;
class Foo {}
interface Bar {
String barMethod();
}
public class TypeUnifailcation extends Foo implements Bar {
@LeifW
LeifW / NumType.idr
Last active May 23, 2020 07:57
A Num instance for Type
import Data.Vect
%default total
Num Type where
(+) = Either
(*) = Pair
fromInteger 0 = Void
fromInteger 1 = Unit
fromInteger 2 = Bool