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
// Reloading modules from the repl in Node.js | |
// Benjamin Gleitzman ([email protected]) | |
// | |
// Inspired by Ben Barkay | |
// http://stackoverflow.com/a/14801711/305414 | |
// | |
// Usage: `node reload.js` | |
// You can load the module as usual | |
// var mymodule = require('./mymodule') | |
// And the reload it when needed |
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
scala> import scalaz._ | |
import scalaz._ | |
scala> import Scalaz._ | |
import Scalaz._ | |
scala> ∅[Boolean] | |
res0: Boolean = false |
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 sbt._ | |
class SQLShellProject(info: ProjectInfo) extends DefaultProject(info) { | |
override def compileOptions = Unchecked :: super.compileOptions.toList | |
// External dependencies | |
val scalaToolsRepo = "Scala-Tools Maven Repository" at | |
"http://scala-tools.org/repo-releases/org/scala-tools/testing/scalatest/0.9.5/" |
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
from itertools import chain | |
def c3(cls, *mro_lists): | |
# Make a copy so we don't change existing content | |
mro_lists = [list(mro_list[:]) for mro_list in mro_lists] | |
# Set up the new MRO with the class itself | |
mro = [cls] | |
while True: | |
candidate_found = False |
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
package org.fishmacs.simulation | |
import scala.actors.Actor | |
import ParallelSimulation._ | |
class Circuit { | |
val clock = new Clock | |
case class SetSignal(sig: Boolean) | |
case class SignalChanged(wire: Wire, sig: Boolean) |
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
if oName.isDefined oName.get.toUpperCase else "Name not present" | |
oName.map(_.toUppercase).getOrElse("Name not presented") |
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 scala.actors.Actor | |
import ParallelSimulation._ | |
class Circuit { | |
val clock = new Clock | |
case class SetSignal(sig: Boolean) | |
case class SignalChanged(wire: Wire, sig: Boolean) | |
val WireDelay = 1 | |
val InverterDelay = 2 |
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 scala.actors.Actor | |
import Actor._ | |
object ParallelSimulation { | |
case class Ping(time: Int) | |
case class Pong(time: Int, from: Actor) | |
case object Start | |
case object Stop | |
case class AfterDelay(delay: Int, msg: Any, target: Actor) |
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
Bitmap bitmap = BitmapFactory.decodeFile("..."); | |
BitmapDrawable drawable = new BitmapDrawable(bitmap); | |
Button button = (Button)findViewById(...); | |
button.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); |
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
function str_repeat(i, m) { | |
for (var o = []; m > 0; o[--m] = i); | |
return o.join(''); | |
} | |
function sprintf() { | |
var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = ''; | |
while (f) { | |
if (m = /^[^\x25]+/.exec(f)) { | |
o.push(m[0]); |