Skip to content

Instantly share code, notes, and snippets.

View hakanai's full-sized avatar
⚔️
Battling i16n demons

Hakanai hakanai

⚔️
Battling i16n demons
View GitHub Profile
Original version
-----------------------------------------------------------------------------------
$ echo "test.text=Test" > Bundle.properties
Sending out for translation
-----------------------------------------------------------------------------------
$ prop2po Bundle.properties Bundle.po
$ cat Bundle.po
#. extracted from Bundle.properties
irb(main):001.0> JRUBY_VERSION
=> "1.5.1"
irb(main):002:0> test = "| 12345678 | 123456789 |"
=> "| 12345678 | 123456789 |"
irb(main):003:0> test.gsub(/(\d\s*){9,}/, 'XXX')
=> "| XXX | XXX|"
irb(main):004:0> test.gsub(/(\d\s*?){9,}/, 'XXX')
=> "| XXX| XXX |"
//
// Find the bug. :-)
//
interface HeavyLifting {
void doSomeBlockingStuff() throws InterruptedException;
}
// meanwhile, somewhere else in the universe:
class MyUsefulUtility {
//
// Find the bug - Hard Mode
//
class SomeSunLibrary {
/**
* @throws InterruptedIOException sometimes, depending on the OS and the moon.
* @throws IOException
*/
void doSomeIO() throws IOException {
import org.hamcrest.Matchers;
public class WtfHamcrest {
@Test
public void testWtfHamcrest()
{
Integer a = 1;
String b = "2";
assertThat(a, Matchers.<Object>is(not(equalTo(b))));
import java.awt.BorderLayout;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
@hakanai
hakanai / gist:893674
Created March 30, 2011 01:03
WHY THE FUCK DOES THIS COMPILE?
public class Overflow
{
public static void main(String[] args)
{
int value = 2000000000;
long increment = 1000000000;
value += increment; // no problemo!
@hakanai
hakanai / NotThreadSafe.java
Created May 4, 2011 01:46
Yet another thing that isn't really clear about thread safety
class NotThreadSafe {
private String value;
public NotThreadSafe() {
value = generateSomehow();
}
public String getValue() {
return value;
}
@hakanai
hakanai / gist:1026482
Created June 15, 2011 04:25
Outlook sucks
Start date: 3 Nisan 5768 (Gregorian: 8 April 2008)
First day of month: 1 Nisan 5768 (Gregorian: 6 April 2008)
Minimum Date: 1 Tishri 5362 (Gregorian: 27 September 1601)
incremented one month: 1 Heshvan 5362
incremented one month: 3 Kislev 5362
incremented one month: 3 Tevet 5362
incremented one month: 5 Shevat 5362
incremented one month: 6 Adar 5362
incremented one month: 5 Nisan 5362
incremented one month: 6 Iyar 5362
// What I would like to write:
UNQUOTED
: UnquotedStartChar UnquotedChar*
{but not matching WSLASH NUMBER}
;
// What it seems I actually have to write:
UNQUOTED