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
# Runs a new "jofrli" session with two windows. | |
# This starts the jofrli service process in one window, and the emacs connecting to it via slime in the other | |
new -s jofrli -n emacs "sudo -u jfrli -i -- -c '/usr/bin/emacs -q -l /opt/lisp/jofrli/production/init.el'" | |
neww -d -t 0 -n lisp "sudo -u jfrli -i -- -c '/opt/lisp/ql/sbcl/bin/sbcl --core /opt/lisp/ql/sbcl/lib/sbcl/sbcl.core --load /opt/lisp/jofrli/production/init.lisp'" |
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 Array | |
def sorted?(&block) | |
case length | |
when 0, 1 then true | |
else | |
init_signum = nil | |
if block | |
init_signum = block.call(self[0]) <=> (prev = block.call(self[1])) | |
else | |
init_signum = self[0] <=> (prev = self[1]) |
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
@doc """ | |
Provides a convenient macro that allows a test to be | |
defined with a string. This macro automatically inserts | |
the atom :ok as the last line of the test. That said, | |
a passing test always returns :ok, but, more important, | |
it forces Elixir to not tail call optimize the test and | |
therefore avoiding hiding lines from the backtrace. | |
## Examples |
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
func unpadPKCS7(data []byte, toSize uint8) int { | |
// Non-costant time operations on length of the message (can | |
// be assumed to be public info): | |
if len(data) == 0 || len(data)%int(toSize) != 0 { | |
return 0 | |
} | |
// Ostensibly(!) constant-time operations only from here on: | |
var lastByteVerbatim, lastByte uint8 | |
var success int |
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
<?xml version="1.0"?> | |
<root> | |
<devicevendordef> | |
<vendorname>APPLE_INC</vendorname> | |
<vendorid>0x05ac</vendorid> | |
</devicevendordef> | |
<devicevendordef> | |
<vendorname>FILCO</vendorname> | |
<vendorid>0x04d9</vendorid> |
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
;;; Patch inf-ruby to load more code by default: | |
(require 'inf-ruby) | |
(setq inf-ruby-console-patterns-alist | |
'(("*.gemspec" . asf-gem) | |
("scripts/bin/console" . pay-server) | |
("Gemfile" . default))) | |
(defun inf-ruby-console-asf-gem (dir) |
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
# Chalk::Dev::Server::ProcessWatcher is an instance of EM::ProcessWatch, | |
# but this should work for all subclasses of EM::Connection. | |
before do | |
@env = proc {} | |
EM::Environment.register_block(@env) | |
@watcher = Chalk::Dev::Server::ProcessWatcher.new(@env) | |
end | |
# To use @watcher now, you don't need EM.run or any shenanigans. |
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
fn sessionNumber(line: &str) -> Option<int> { | |
match(line.as_slice().split_iter(':').next()) { | |
Some(first) => int::from_str(first), | |
_ => None | |
} | |
} | |
fn occupiedSessions(output: ~str) -> @HashSet<int> { | |
let set = @HashSet::new(); | |
for line in output.line_iter(){ |
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
#[fixed_stack_segment] | |
fn exec_program(program: &str, args: &[~str]) { | |
do program.to_c_str().with_ref() |c_program| { | |
// I don't much care about the ownership of the strings here | |
// at this point, so let's just fail if execvp isn't working. | |
unsafe { | |
let c_args = args.map(|arg| { arg.to_c_str().unwrap() }); | |
// c_args needs a NULL attached to the end though. Here's what I tried: | |
// let c_args = args.map(|arg| { arg.to_c_str().unwrap() }) + [ptr::null()]; // this screams about unconstrained types. | |
execvp(c_program, vec::raw::to_ptr(c_args)); |
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 | |
require 'optparse' | |
def exp_notation(n) | |
Math.log10(n).floor | |
end | |
def main | |
options = {} |