Skip to content

Instantly share code, notes, and snippets.

View diegopacheco's full-sized avatar

Diego Pacheco diegopacheco

View GitHub Profile
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@diegopacheco
diegopacheco / times.log.txt
Created March 16, 2012 23:57
Scala Times
PURE JAVA Arch(2.8.7.7) JBoss Boot Up
=======================================
21:49:04,594 INFO [ServerImpl] JBoss (Microcontainer)
[5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 29s:278ms
Scala/JAVA Arch(3.0.0)Jboss Boot UP
====================================
21:39:15,830 INFO [ServerImpl] JBoss (Microcontainer)
@diegopacheco
diegopacheco / monad-state.hs
Created March 7, 2012 01:41
Haskell Monad state that Works! GHCI 7.0.4 = 2012
import Control.Monad.State
import Control.Monad
data FibState = F {previous, current :: Integer}
fibState0 = F {previous = 1, current = 0}
currentFib :: State FibState Integer
currentFib = gets current
nextFib :: State FibState Integer
@diegopacheco
diegopacheco / haskell-monad-maybe.hs
Created March 6, 2012 23:41
Monad Maybe Haskell
instance Monad Maybe where
return x = Just x
Nothing >>= f = Nothing
Just x >>= f = f x
fail _ = Nothing
@diegopacheco
diegopacheco / monad.hs
Created March 6, 2012 23:37
Haskell Monad
class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
x >> y = x >>= \_ -> y
fail :: String -> m a
fail msg = error msg
@diegopacheco
diegopacheco / bash_profile_tips.sh
Created January 22, 2012 17:33
How to Create a .bash_profile in Cygwin
cd /
mkdir /home/diegopacheco
echo "export HOME=/home/diegopacheco" >>.bashrc
echo "export HOME=/home/diegopacheco" >>.bash_profile
cp .bashrc .bash_profile /home/diegopacheco
echo "cd" >>.bashrc
@diegopacheco
diegopacheco / 2-meetup-functional-society.md
Created January 15, 2012 19:16
Functional Society #2 meetup 25/02/2012

Meetup 25/02/2012

It's time!!! Let's do another kick ass event at Porto Alegre.

Where?

671, Jari st - Passo da Areia - Porto Alegre | Google Maps Adress => http://g.co/maps/frjub
Ask for "Functional Society" or "Alexandre Poletto"

@diegopacheco
diegopacheco / fp_concepts_1.md
Created January 15, 2012 18:50
Functional Society - FP Concepts: Higher Order Functions, Currying and Lambda

This gist and a Functional Society Gist to talk about FP concepts, so people can share links and help each other to get the concepts right and make questions, get you question answered and so on and on...

3 FP Concepts

  • Higher Order Functions
  • Lambda
  • Currying

Some useful resources

;
; Monads
; ======
;
; * Without monads "pure" functional programming could be very impractical, Hack!
; * You can build environments that support exactly the features that you want
; * Functional able todo IO
; * Function Composition: LINQ, Unix Pipes
; * Good for control tracking of things
; * Encapsulating two things:
@headius
headius / results
Created January 10, 2012 20:05
Compare Nokogiri on JRuby (Apache Xerces) with 1.9.3 (libxml2)
system ~/projects/nokogiri $ pickjdk 1
New JDK: 1.6.0.jdk
system ~/projects/nokogiri $ jruby -v xmlbench.rb
jruby 1.7.0.dev (ruby-1.8.7-p357) (2012-01-10 bd4cc62) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]
11.331000 0.000000 11.331000 ( 11.331000)
10.239000 0.000000 10.239000 ( 10.239000)
10.185000 0.000000 10.185000 ( 10.185000)
10.113000 0.000000 10.113000 ( 10.113000)
10.120000 0.000000 10.120000 ( 10.120000)