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
(* | |
MIT License | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
*) | |
on run {input, parameters} | |
set inactivePath to "/System/Library/CoreServices/Dock.app.bak" | |
set activePath to "/System/Library/CoreServices/Dock.app" | |
if application "Dock" is running then |
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
#!/bin/zsh | |
######################################################################################################################### | |
# MIT License | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 gistard.test | |
object Verify extends App { | |
println("OK") | |
} |
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
abstract class some[X](val value : X) { type T = X } | |
abstract class someFactory[S <: some[_]](val P : (S#T) => boolean) | |
{ | |
def apply(t : S#T) : Option[S] = if(P(t)) Some(fetch(t)) else None | |
def unapply(s : S) : Option[S#T] = if(s == null) None else Some(s.value) | |
def fetch(t : S#T) = mk(t) |
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
//isValid = predicate/constraint | |
abstract class Type[T](val isValid : (T) => boolean) | |
{ | |
//X is the reference type | |
final protected[Type] case class X[T] (val value : T) { | |
override def toString = Type.this.getClass.getSimpleName + "(" + value + ")" | |
} | |
//Type is the alias for X[T] that we expose to the outside world | |
type Type = X[T] |
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 Test { | |
trait Mapping { | |
def get[T](clazz : Class[T]) : T | |
} | |
trait Injector { | |
protected val mapping : Mapping | |
def inject[T](implicit manifest : scala.reflect.Manifest[T]) = mapping.get(manifest.erasure.asInstanceOf[Class[T]]) | |
} |
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
//Usage: | |
//override def pomPostProcess(node: Node): Node = mcPom(moduleConfigurations)(super.pomPostProcess(node)) | |
trait McPom { self: DefaultProject => | |
import scala.xml._ | |
def mcPom(mcs: Set[ModuleConfiguration])(node: Node): Node = { | |
//make sure we have a trailing slash so we deduplicate URLs properly | |
def cleanUrl(url: String) = url match { | |
case 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
/** | |
* I had a question directed at me, on how to encode the following scenario in Akka Actors, | |
* as for Scala Actors one would simply nest the receives. | |
* | |
* Recuirements are as follows: | |
* The first thing the actor needs to do, is to subscribe to a channel of events, | |
* Then it must replay (process) all "old" events | |
* Then it has to wait for a GoAhead signal to begin processing the new events | |
* It mustn't "miss" events that happen between catching up with the old events and getting the GoAhead signal | |
*/ |
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
class MiniSTM[T <: AnyRef](initialValue: T) { | |
private val value = new AtomicReference[T](initialValue) | |
def apply(fun: T => T) { | |
@tailrec def update(expect: T): Unit = | |
if ( !value.compareAndSet(expect, fun(expect)) ) update(value.get) | |
update(value.get) | |
} | |
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
trait PostStart { actor: Actor => | |
def postStart: Unit | |
override def preStart { | |
actor.become { | |
case "PostStart" => try { postStart } finally { actor.unbecome } | |
} | |
actor.self ! "PostStart" | |
} | |
} |
OlderNewer