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
$ ls src | |
Simple.java SimpleTest.java | |
$ cat src/Simple.java | |
public class Simple { | |
public static int add(int x, int y) { | |
return x + y; | |
} | |
} | |
$ cat src/SimpleTest.java | |
import org.junit.Test; |
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
diff -r b88aa723a5fa src/solaris/classes/sun/nio/fs/UnixPath.java | |
--- a/src/solaris/classes/sun/nio/fs/UnixPath.java Thu Oct 24 09:10:42 2013 -0700 | |
+++ b/src/solaris/classes/sun/nio/fs/UnixPath.java Fri Oct 25 07:13:55 2013 -0500 | |
@@ -145,7 +145,7 @@ | |
} | |
if (error) { | |
throw new InvalidPathException(input, | |
- "Malformed input or input contains unmappable chacraters"); | |
+ "Malformed input or input contains unmappable characters"); | |
} |
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
extern mod extra; | |
use std::*; | |
use extra::*; | |
fn main() { | |
let reader = io::file_reader(&Path(os::args()[1])).unwrap(); | |
let writer = io::file_writer(&Path(os::args()[2]), | |
[io::Append, io::Create]).unwrap(); | |
let mut lines = reader.read_lines(); | |
sort::quick_sort3(lines); | |
for l in lines.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
extern mod std; | |
fn main() { | |
let input = io::file_reader(&Path(os::args()[1])); | |
let output = result::get(&io::file_writer(&Path(os::args()[2]), [io::Append, io::Create])); | |
let mut lines = result::get(&input).read_lines(); | |
std::sort::quick_sort(lines, |a,b| { | |
str::le(*a, *b) | |
}); | |
for lines.each |l| { | |
output.write_line(*l); |
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 | |
# Given a number x, print a diamond of all numbers from 1 to x^2 in the following format | |
# 2: 3: | |
# 1 1 | |
# 3 2 4 2 | |
# 4 7 5 3 | |
# 8 6 | |
# 9 | |
def num_for num, i, j | |
res = num*i+j*(1-num) |
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
public void testGetUnicodeValue() throws Exception { | |
byte[] bytes = new byte[] { | |
110, 122, -31, 32, 75 | |
}; | |
RubyString str = RubyString.newStringLight(Ruby.getGlobalRuntime(), new ByteList(bytes)); | |
assertEquals(5, ((Integer)str.length().toJava(Integer.class)).intValue()); | |
assertEquals(5, str.getUnicodeValue().length()); | |
} | |
// In RubyEncodings: |
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
# Not sure where this is defined in MRI, but appeared to be missing in JRuby | |
if defined?(JRUBY_VERSION) && RUBY_VERSION =~ /^1\.9/ | |
class KeyError < IndexError | |
end | |
class String | |
alias_method :old_format, :% | |
def %(replacements) | |
split_re = /(?<!%)(%{[^}]+})/ | |
replace_re = /(?<!%)%{([^}]+)}/ |
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
module Arel | |
module Visitors | |
class DepthFirst < Arel::Visitors::Visitor | |
def initialize block = nil | |
@block = block || Proc.new | |
if defined?(JRUBY_VERSION) | |
require 'java' | |
if @block.to_java.block.arity.nil? | |
@block = lambda { |c| nil } | |
end |
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
Java: | |
import java.lang.StringBuilder; | |
public class Test { | |
public static String concat(String... strings) { | |
StringBuilder sb = new StringBuilder(); | |
for( String s : strings ) { | |
sb.append(s); | |
} | |
return sb.toString(); | |
} |
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
$ sh create_blitz.sh | |
qemu-system-x86_64: -net vnic,vlan=0,name=vnic0,ifname=rge0,macaddr=90:b8:d0:c0: | |
ff:ee: vnic dhcp disabled | |
QEMU 0.14.1 monitor - type 'help' for more information | |
(qemu) Start bios (version 0.6.1.2-20110201_165504-titi) | |
Ram Size=0x18000000 (0x0000000000000000 high) | |
CPU Mhz=2934 | |
PCI: pci_bios_init_bus_rec bus = 0x0 | |
PIIX3/PIIX4 init: elcr=00 0c |