Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Asymmetric Finance
  • /dev/null
View GitHub Profile
@wheresalice
wheresalice / gist:883191
Created March 23, 2011 14:36
Arduino Redis client - pushes a message to a Redis list
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 2, 10 }; // this is the ip within my lan
byte gateway[] = { 192, 168, 2, 254 }; // neccessary to get access to the internet via your router
byte subnet[] = { 255, 255, 255, 0 };
byte server[] = { 192, 168, 2, 50 }; // Redis Server
String list = "jobs";
String message = "hello world";
@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 April 28, 2024 12:29
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 March 22, 2024 20:18
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') =