java convert codepoint to string

either of these two would do it, probably prefer the former, ref

  private static String codePointToString(int codePoint) {
    return new String(Character.toChars(codePoint));
  }
private static String codePointToString(int codePoint) {
  StringBuilder stringOut = new StringBuilder();
  stringOut.appendCodePoint(codePoint);
  return stringOut.toString();
}

eternal input stream

here’s a faux one that “reads forever”

 

eternalInputStream = new InputStream() {
  boolean closed = false; // simulate what a file read does...kind of.

  @Override
  public void close() throws IOException {
    closed = true;
  }

  @Override
  public int read() throws IOException {
    throw new UnsupportedOperationException("shouldnt need this for unit test but the class signature requires its definition");
  }

  @Override
  public int read(byte b[], int off, int len) throws IOException {
    if (closed) {
      throw new IOException("stream already closed");
    }
    return 1; // who cares what the bytes actually even are LOL
  }
};

jruby ArgumentError: Constructor invocation failed: null

this meant (for me) “you have default-jre-headless installed and are subclassing a JFrame” which doesn’t work right…

so for me it was

sudo apt-get install openjdk-default

to get the non headless one

you can see the real error exception message by not subclassing one but just creating it:

jruby-1.7.16 :001 > require ‘java’
=> false
jruby-1.7.16 :002 > javax.swing.JFrame.new

this should always work…if not then install the non headless package of your jdk.

 

https://github.com/jruby/jruby/issues/2243

installing package uuid-devel gives wrong .pc filename /usr/lib64/pkgconfig/ossp-uuid.pc should be uuid.pc

this meant “use the  libuuid-devel package instead of uuid-devel”

 

/usr/bin/uuid-config
/usr/include/uuid.h
/usr/lib64/libossp-uuid.so
/usr/lib64/pkgconfig/ossp-uuid.pc
/usr/share/man/man3/ossp-uuid.3.gz
packrd@dpsprod-app07.a|dpsprod:~/ltfs-1.2.6$ repoquery -l libuuid-devel
/usr/include/uuid
/usr/include/uuid/uuid.h
/usr/lib/libuuid.a
/usr/lib/libuuid.so
/usr/lib/pkgconfig/uuid.pc

postgres unique substring slow

postgres string index with first characters

whatever

anyway the answer is, if you want to query based on a known substring

ok, if you want “like ‘abc%’ then postgres has a special type of index; (I think http://www.postgresql.org/docs/8.1/static/indexes-opclass.html varchar_ops or what not…ymmv).

For us, who had a slow select unique substr then adding an index that was the exact same size works:

 

http://stackoverflow.com/questions/17633344/is-there-a-way-to-index-in-postgres-for-fast-substring-searches