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
(* | |
Installation instructions | |
========================= | |
Run as an Application: | |
1) Open AppleScript Editor and create a new script | |
2) Paste this file into it | |
3) Save name it '§(Toggle Wi-Fi)' | |
- Or substitute '§' for a symbol that you can press with a single key | |
4) Put it in Applications/Utilities |
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
//Warning: Uses Akka internal APIs (not binary compatible), | |
//can be written not to depend on that but implemented like this for brevity. | |
package akka.util | |
trait CallbackExecutionContext { this: akka.actor.Actor ⇒ | |
// Defines our signal for callback execution | |
case object Execute | |
// ``SerializedSuspendableExecutionContext`` is Akka-internal | |
private[this] final val ssec: SerializedSuspendableExecutionContext = { |
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
*** /Users/viktorklang/.oh-my-zsh/plugins/git/git.plugin.zsh.old Fri May 10 18:07:33 2013 | |
--- /Users/viktorklang/.oh-my-zsh/plugins/git/git.plugin.zsh Fri May 10 18:05:49 2013 | |
*************** alias gcount='git shortlog -sn' | |
*** 14,19 **** | |
--- 14,21 ---- | |
alias gcp='git cherry-pick' | |
alias glg='git log --stat --max-count=5' | |
+ alias grm='git branch -D' | |
+ |
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
/* | |
Copyright 2018 Viktor Klang | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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
/* | |
Copyright 2013 Viktor Klang | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and |
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
/*©2013 Viktor Klang*/ | |
package akka.util | |
import java.util.concurrent.atomic.AtomicReference | |
import scala.concurrent.{ Future, ExecutionContext } | |
import scala.annotation.tailrec | |
class Cache[K, V](__ec: ExecutionContext, throughput: Int) extends AtomicReference[Map[K, V]] { | |
implicit val executor = SerializedSuspendableExecutionContext(throughput)(__ec) | |
@tailrec final def update(f: Map[K, V] ⇒ Map[K, V]): Map[K, V] = { | |
val v = get | |
val nv = f(v) |
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 java.util.concurrent.ConcurrentLinkedQueue | |
import java.util.concurrent.atomic.AtomicInteger | |
import scala.concurrent.ExecutionContext | |
import scala.util.control.NonFatal | |
import scala.annotation.tailrec | |
object SerializedExecutionContext { | |
def apply(batchSize: Int)(implicit context: ExecutionContext): ExecutionContext = { | |
require(batchSize > 0, s"SerializedExecutionContext.batchSize must be greater than 0 but was $batchSize") | |
new ConcurrentLinkedQueue[Runnable] with Runnable with ExecutionContext { | |
private final val on = new AtomicInteger(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
/** | |
* "Select" off the first future to be satisfied. Return this as a | |
* result, with the remainder of the Futures as a sequence. | |
* | |
* @param fs a scala.collection.Seq | |
*/ | |
def select[A](fs: Seq[Future[A]])(implicit ec: ExecutionContext): Future[(Try[A], Seq[Future[A]])] = { | |
@tailrec | |
def stripe(p: Promise[(Try[A], Seq[Future[A]])], | |
heads: Seq[Future[A]], |
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
/** | |
* Mix in this trait to suppress the StackTrace for the instance of the exception but not the cause, | |
* scala.util.control.NoStackTrace suppresses all the StackTraces. | |
*/ | |
trait OnlyCauseStackTrace { self: Throwable ⇒ | |
override def fillInStackTrace(): Throwable = { | |
setStackTrace(getCause match { | |
case null ⇒ Array.empty | |
case some ⇒ some.getStackTrace |
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
object NettyFutureBridge { | |
import scala.concurrent.{ Promise, Future } | |
import scala.util.Try | |
import java.util.concurrent.CancellationException | |
import org.jboss.netty.channel.{ Channel, ChannelFuture, ChannelFutureListener } | |
def apply(nettyFuture: ChannelFuture): Future[Channel] = { | |
val p = Promise[Channel]() | |
nettyFuture.addListener(new ChannelFutureListener { | |
def operationComplete(future: ChannelFuture): Unit = p complete Try( |