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 Merge { | |
def m_way_merge(out: List[Int], xs: List[List[Int]]): List[Int] = { | |
val arrays = xs.remove(_ == Nil) | |
if (arrays.isEmpty) { | |
out | |
} else { | |
val idx: Int = arrays.findIndexOf((xs: List[Int]) => xs.head == arrays.map(_.head).sort(_ < _).head) | |
m_way_merge(out ::: List(arrays(idx).head), arrays.slice(0, idx) ::: arrays.slice(idx + 1, arrays.length) ::: List(arrays(idx).tail)) | |
} | |
} |
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
Index: src/main/scala/sbt/DefaultProject.scala | |
=================================================================== | |
--- src/main/scala/sbt/DefaultProject.scala (revision 1129) | |
+++ src/main/scala/sbt/DefaultProject.scala (working copy) | |
@@ -445,7 +445,7 @@ | |
{ | |
log.warn("No Main-Class attribute will be added automatically added:") | |
log.warn("Multiple classes with a main method were detected. Specify main class explicitly with:") | |
- log.warn(" override mainClass = Some(\"className\")") | |
+ log.warn(" override def mainClass = Some(\"className\")") |
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 FooBar extends Specification { | |
"Foo" should { | |
var i = 0 | |
doFirst { i = 1 } | |
doLast { i = 0 } | |
"this should not be 1" in { | |
i mustEqual 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
.equiv GPIO_BASE_ADDR, 0x0E0028000 | |
.equiv IOCLR0, GPIO_BASE_ADDR + 0x0C | |
.equiv IODIR0, GPIO_BASE_ADDR + 0x08 | |
.equiv RED_LED, 1 << 18 | |
.globl _start | |
_start: | |
ldr r1, =IODIR0 | |
ldr r2, =RED_LED | |
str r2, [r1] |
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
/** | |
* This is an exmaple of how to program in scala without the use of imports or | |
* global namespaces. Foo seeing Bar's members does not rely on the fact | |
* that they are in the same package. | |
* | |
* Inspired by Gilad Bracha's talk at the Emerging Languages conference in 2010. | |
* | |
* Built with scala 2.8.0-final | |
*/ |
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
# for when I acccidentally try to val foo = bar something. | |
def val x | |
x | |
end | |
val foo = 1 + 2 | |
puts "#{foo}" # ==> 3 | |
# Yeah, just jam that into Kernel like everybody else. why not? |
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
$x = 0; | |
sub f { return $x; } | |
sub g { my $x = 1; return f(); } | |
print g()."\n"; | |
# the power of scoping compels you, change global $y! | |
$y = 0; | |
sub f1 { return $y; } | |
sub g1 { local $y = 1; return f1(); } |
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 java.net._ | |
import java.util.UUID | |
import com.twitter.conversions.time._ | |
import com.twitter.finagle.builder.ClientBuilder | |
import com.twitter.util._ | |
import java.nio.charset.Charset | |
import org.jboss.netty.buffer.{ChannelBuffers, ChannelBuffer} | |
import org.jboss.netty.handler.codec.http._ | |
import com.twitter.finagle.stream.Stream |
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
;; emacsd-tile.el -- tiling windows for emacs | |
(defun swap-with (dir) | |
(interactive) | |
(let ((other-window (windmove-find-other-window dir))) | |
(when other-window | |
(let* ((this-window (selected-window)) | |
(this-buffer (window-buffer this-window)) | |
(other-buffer (window-buffer other-window)) | |
(this-start (window-start this-window)) |
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
#!/usr/bin/ruby | |
# | |
# find all domains that bit-squat a given domain. | |
# | |
# Based on this article: http://domainincite.com/bit-squatting-%E2%80%93-the-latest-risk-to-domain-name-owners/ | |
# | |
# improvements: use a regex rather than URI.parse | |
require 'uri' |