Skip to content

Instantly share code, notes, and snippets.

@fishmacs
fishmacs / reload.js
Last active August 29, 2015 14:24 — forked from gleitz/reload.js
// 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
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> ∅[Boolean]
res0: Boolean = false
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/"
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
@fishmacs
fishmacs / gist:4641607
Last active December 11, 2015 18:28
changed Circuit.scala(use List)
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)
@fishmacs
fishmacs / gist:4462013
Created January 5, 2013 15:05
scala tips 1
if oName.isDefined oName.get.toUpperCase else "Name not present"
oName.map(_.toUppercase).getOrElse("Name not presented")
@fishmacs
fishmacs / gist:3683685
Created September 9, 2012 10:31
Circuit in Prgramming in Scala
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
@fishmacs
fishmacs / gist:3673439
Created September 8, 2012 10:54
ParallelSimulation in Programming in Scala
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)
@fishmacs
fishmacs / gist:3432574
Created August 23, 2012 04:52
android/bitmap/drawable/button
Bitmap bitmap = BitmapFactory.decodeFile("...");
BitmapDrawable drawable = new BitmapDrawable(bitmap);
Button button = (Button)findViewById(...);
button.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
@fishmacs
fishmacs / gist:2180487
Created March 24, 2012 09:10
js/sprintf
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]);