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/env ruby | |
# A brute-force letterpress board searcher. It takes about 90 seconds to search a board. | |
# | |
# Good uses: train on your vocabulary with boards you lost on. | |
# | |
# LAZY AND STUPID CHEATERS: DO NOT USE THIS FOR CHEATING. CHEATERS NEVER WIN. | |
class BoardSearcher | |
attr_reader :board |
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 can make a case that queues only do what people want if you don’t consider failure cases. | |
Qs are empty (normal) or full (fail). Normally things are processed quickly. Failure case processing time is unbounded (or “too long”). | |
Solution is always “dump the Q”. Which means you do care about how long it takes to process items. So you want the queue to always be empty | |
Which means you only want a non-failing Q. | |
So why not admit it, use in-proc buffers, run enough servers to handle load? Reject work up front instead of dropping oldest items w/… |
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' |
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
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
$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
# 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
/** | |
* 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
.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
object FooBar extends Specification { | |
"Foo" should { | |
var i = 0 | |
doFirst { i = 1 } | |
doLast { i = 0 } | |
"this should not be 1" in { | |
i mustEqual 0 | |
} |