This file contains 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 string | |
import re | |
alpha = raw_input('alpha: ') | |
seq = raw_input('seq: ') | |
name = raw_input('text: ') | |
seq = map(int, list(seq.replace(" ",""))) | |
f = dict(zip(list(string.ascii_lowercase), map(int, list(alpha.replace(" ",""))))) |
This file contains 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
<link rel="import" href="../core-ajax/core-ajax.html"> | |
<link rel="import" href="../paper-tabs/paper-tabs.html"> | |
<link rel="import" href="../paper-tabs/paper-tab.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<polymer-element name="my-element"> | |
<template> |
This file contains 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
<link rel="import" href="../google-map/google-map.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; |
This file contains 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
/** Domain mapped XML doesnt have to be a boilerplate filled annotational mess. Using shapeless automatic | |
* typeclass derivation and a little scalaz magic, it becomes painless. Requires shapeless-2.1.0 and scala >2.10 | |
* | |
* | |
* import scalaz._ | |
* import scalaz.std._ | |
* import anyVal._ | |
* import list._ | |
* import scala.xml._ | |
* |
This file contains 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
/** | |
The Play (2.3) json combinator library is arguably the best in the scala world. However it doesnt | |
work with case classes with greater than 22 fields. | |
The following gist leverages the shapeless 'Automatic Typeclass Derivation' facility to work around this | |
limitation. Simply stick it in a common location in your code base, and use like so: | |
Note: ** Requires Play 2.3 and shapeless 2.1.0 | |
import SWrites._ | |
import SReads._ |
This file contains 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
object log { | |
class LineOfCode() { | |
val loc = { | |
val list = Thread.currentThread.getStackTrace.toList | |
list match { | |
case (_ :: _ :: _ :: loc :: loc2 :: _) => s"${loc2.getFileName}:${loc2.getLineNumber}->${loc.getFileName}:${loc.getLineNumber}" | |
case _ => "" | |
} | |
} | |
} |
This file contains 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
/** | |
The Play (2.3) json combinator library is arguably the best in the scala world. However it doesnt | |
work with case classes with greater than 22 fields. | |
The following gist leverages the shapeless 'Automatic Typeclass Derivation' facility to work around this | |
limitation. Simply stick it in a common location in your code base, and use like so: | |
Note: ** Requires Play 2.3 and shapeless 2.0.0 | |
This file contains 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
//The collect function below returns an Enumerator[Activity], given some target meta-data | |
val iterateePromise = collect(target) &> fileWriting |>> updatingCursor | |
iterateePromise.flatMap(_.run) |
This file contains 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
/* Status updating and reporting iteratee*/ | |
def updatingStatus:Iteratee[ErrorOrActivity,Unit] = Iteratee.foreach[ErrorOrActivity] { | |
case Left(error) => | |
reportError(error) | |
statsd("collector.error") | |
case Right(activity) => | |
reportSuccess(activity) | |
statsd("collector.success") | |
} |
This file contains 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
object KloutEnumeratee { | |
def flatMapInput[From] = new { | |
def apply[To](f: Input[From] => PlayPromise[Input[To]]) = | |
new Enumeratee.CheckDone[From, To] { //Checkdone is part of the Play Iteratee library | |
def step[A](k: K[To, A]): K[From, Iteratee[To, A]] = { | |
case in @ (Input.El(_) | Input.Empty) => | |
val promiseOfInput = f(in) | |
Iteratee.flatten(promiseOfInput map { input => | |
new CheckDone[From, To] { | |
def continue[A](k: K[To, A]) = Cont(step(k)) |
NewerOlder