Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Bivalent Capital
  • /dev/null
View GitHub Profile
@retronym
retronym / forall.scala
Created November 26, 2011 18:21
universal quantification
scala> trait Forall[F[_]]{ def apply[A]: F[A] }
defined trait Forall
scala> type ListFun[A] = List[A] => List[A]
defined type alias ListFun
scala> object Reverse extends Forall[ListFun] { def apply[A] = _.reverse}
defined module Reverse
scala> Reverse[String](List("1", "2"))
@einblicker
einblicker / gist:1521202
Created December 26, 2011 13:51
operational monad
object OperationalMonad extends App {
class Operational {
type instr[A] <: { def run: A }
sealed abstract class Program[A] {
def map[B](k: A => B) = flatMap(k andThen Lift.apply)
def flatMap[B](k: A => Program[B]): Program[B] = {
Bind(this, k)
}
def run: A
}
@blouerat
blouerat / Reader.scala
Created June 6, 2012 03:53
Reader Monad
/*
Based on the first part of the talk "Dead-Simple Dependency Injection in Scala" by @runarorama at NEScala 2012
http://marakana.com/s/dependency_injection_in_scala,1108/index.html
*/
class Connection {
def prepareStatement(query: String) = new Statement()
}
class Statement {
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 15, 2025 05:11
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@stew
stew / foo.scala
Created July 1, 2012 11:44
Reader Monad + Validation
import scalaz._
import Scalaz._
object Foo {
type Result[A] = Validation[String,A]
type Reader[A] = Int => Result[A]
implicit val readerBind: Bind[Reader] = new Bind[Reader] {
def map[A,B](fa: Reader[A])(f: A=>B) : Reader[B] = x => fa(x) map f
def bind[A,B](fa: Reader[A])(f: A => Reader[B]) : Reader[B] = {
@nvanderw
nvanderw / Stack.hs
Created August 22, 2012 04:56
Stack-based programming using monad transformers
import Control.Monad
import Control.Monad.Identity (runIdentity)
import Control.Monad.Error
import Control.Monad.State.Lazy
import Data.Maybe (listToMaybe)
-- |Monad transformer which stores a stack internally
type StackT s m = StateT [s] m
@loicdescotte
loicdescotte / Forcomptran.md
Last active May 27, 2023 06:27
Scala for comprehension translation helper

Scala for comprehension translation helper

"For comprehension" is a another syntaxe to use map, flatMap and withFilter (or filter) methods.

yield keyword is used to aggregate values in the resulting structure.

This composition can be used on any type implementing this methods, like List, Option, Future...

@P7h
P7h / IntelliJ_IDEA__Perf_Tuning.txt
Last active October 21, 2024 01:10
Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
@jroesch
jroesch / Typeclass.md
Last active October 23, 2016 15:37
A description of how to translate Haskell style typeclasses to Scala.

Given a Haskell Typeclass:

class Point a where 
     distance :: a -> a -> Double

data Point2D = Point2D { x :: Int
                       , y :: Int } deriving (Show, Eq)

instance Point Point2D where
 distance (Point2D x y) (Point2D x' y') = 
@mattt
mattt / uiappearance-selector.md
Last active February 7, 2025 15:27
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \