This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// have | |
val params = ( | |
(postalCode |> notNone("postal code missing")) |@| | |
(countryCode |> notNone("country code missing")).flatMap(validIso2CountryCode("country code invalid")) | |
) | |
// would like | |
val params = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
import scala.xml.XML | |
val ServiceUrl = "http://services.postcodeanywhere.co.uk/PostcodeAnywhereInternational/interactive/RetrieveByPostalCode/v2.20/xmla.ws" | |
val params = Map( | |
"key" -> "UP26-TZ93-TK96-PJ69", | |
"country" -> "United Kingdom".toUpperCase, | |
"postalcode" -> "11312".replaceAll(" ", "")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
log 127.0.0.1 local0 | |
# log 127.0.0.1 local1 notice | |
#log loghost local0 info | |
#maxconn 4096 | |
chroot /usr/share/haproxy | |
user haproxy | |
group haproxy | |
daemon | |
#debug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package prob | |
import scalaz._ | |
import Scalaz._ | |
import org.scalacheck.{ Arbitrary, Gen } | |
/** Types for working with probabilities, i.e. values of type `Double` in range `[0.0, 1.0]`. */ | |
object `package` { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################### | |
# git | |
##################### | |
alias g=git | |
alias s='g status' | |
alias gs='g status' | |
alias a='g add' | |
alias ga='g add' | |
alias gap='ga -p' | |
alias gf='g fetch' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rm -f *.class; fsc -shutdown | |
[Compile server exited] | |
$ time scala test.scala | |
real 0m5.779s <-------- | |
user 0m0.375s | |
sys 0m0.069s | |
-------------------------- | |
~/code/scala/testtask$ fsc # käivitab fsc daemoni |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Extractor[T, U] { def unapply(x: T): Option[U] } | |
object Extractor { | |
def apply[T, U](f: PartialFunction[T, U]) = new Extractor[T, U] { | |
def unapply(x: T) = f.lift(x) | |
} | |
} | |
val EmployedAt = Extractor[Person, Company] { | |
case Person(_, _, Some(Position(_, Some(c)))) => c | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... snip | |
class Cell(_BaseCell): # TODO: inherit from Greenlet? | |
uri = None | |
hub = None | |
impl = None | |
proc = None | |
stash = None | |
stopped = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Traceback(object): | |
@classmethod | |
def parse(cls, tb_str): | |
tb_lines = tb_str.strip().split('\n') | |
firstline = tb_lines.pop(0) | |
step_lines = [] | |
while True: | |
if tb_lines[0].startswith(' '): | |
step_lines.append(tb_lines.pop(0)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "importing problematic_module through other_module:" | |
try: | |
import other_module | |
except Exception as e: | |
print "...got", e | |
print "importing problematic_module directly:" | |
try: | |
import problematic_module | |
except Exception as e: |