Skip to content

Instantly share code, notes, and snippets.

drop schema public cascade;
drop extension plv8;
create schema public;
irb(main):001:0> class Request; end
=> nil
irb(main):002:0> Request.class
=> Class
irb(main):003:0> Request.new.class
=> Request
irb(main):004:0> Request.new.class.to_s
=> "Request"
@naaman
naaman / network-interface-patch-notes
Last active December 15, 2015 17:38
Notes on patching NetworkInterface.c
$ cd $ICEDTEA_PATH
$ find . -name NetworkInterface.c
./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c
...
$ cp ./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c ./NetworkInterface.c
$ vi NetworkInterface.c
/fscanf
note: fscanf should only match one line
replace first 02x with 08x
:wq
@naaman
naaman / 8009591-network_interface.patch
Last active December 15, 2015 17:38
JDK NetworkInterface Linux Patch
--- ./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c 2013-03-04 21:51:01.000000000 +0000
+++ ./openjdk/jdk/src/solaris/native/java/net/NetworkInterface.c 2013-04-02 22:35:56.000000000 +0000
@@ -1127,7 +1127,7 @@
uint8_t ipv6addr[16];
if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) {
- while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n",
+ while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n",
addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4], addr6p[5], addr6p[6], addr6p[7],
&if_idx, &plen, &scope, &dad_status, devname) != EOF) {
@naaman
naaman / fucking-java.sh
Created March 13, 2013 22:32
java -version
java -version 2>&1 | head -1 | sed "s/[^0-9\.\_\-]*//g"
@naaman
naaman / gist:5095220
Created March 5, 2013 23:09
anorm hack to use row cursors
// hack to get a Stream with a cursor-backed query because anorm doesn't combine the two
private def resultSetToStream(sql: SimpleSql[Row])(implicit c: Connection): Stream[SqlRow] = {
val stmt = sql.getFilledStatement(c, getGeneratedKeys = false)
stmt.setFetchSize(1000)
val rs = stmt.executeQuery()
val rsMetaData = Sql.metaData(rs)
val columns = List.range(1, rsMetaData.columnCount + 1)
def data(rs: java.sql.ResultSet) = columns.map(nb => rs.getObject(nb))
Useful.unfold(rs)(rs => if (!rs.next()) { rs.getStatement.close(); None } else Some((new SqlRow(rsMetaData, data(rs)), rs)))
}
@naaman
naaman / gist:4993390
Created February 20, 2013 06:22
jdk dyno scratch
1 ls -lah
2 curl -O http://icedtea.wildebeest.org/download/source/icedtea-2.1.5.tar.gz
3 tar xvzf icedtea-2.1.5.tar.gz
4 cd icedtea-2.1.5
5 ./configure --with-parallel-jobs=2 --disable-docs --disable-bootstrap --with-jdk-home=/usr/lib/jvm/java-6-openjdk
6 cd ..
7 curl -O http://mirror.olnevhost.net/pub/apache//ant/binaries/apache-ant-1.8.4-bin.tar.gz
8 tar xf apache-ant-1.8.4-bin.tar.gz
9 ls -lah
10 ls -lah apache-ant-1.8.4
@naaman
naaman / SecurityListings.java
Created September 12, 2012 22:26
List JCE Algorithms
import java.security.Provider;
import java.security.Security;
public class SecurityListings {
public static void main(String[] args) {
for (Provider provider : Security.getProviders()) {
System.out.println("Provider: " + provider.getName());
for (Provider.Service service : provider.getServices()) {
System.out.println(" Algorithm: " + service.getAlgorithm());
}
@naaman
naaman / multi-jdk-live.md
Created September 6, 2012 18:11
Multi JDK Live
~/dev/bb[master] ★ heroku create
Creating shrouded-wave-4655... done, stack is cedar
http://shrouded-wave-4655.herokuapp.com/ | git@heroku.com:shrouded-wave-4655.git
Git remote heroku added
~/dev/bb[master] ★ git push heroku master 
Counting objects: 25, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (25/25), 2.83 KiB, done.
@naaman
naaman / updated-jdk-support.md
Created June 19, 2012 22:33
Updated JDK Support

Updated JDK Support

Heroku now offers beta support for OpenJDK 7, as well as an updated version of OpenJDK 6. Support for both JDKs are available in a new buildpack. OpenJDK 6 is still the default, but the version has been increased to u25 from u20 -- changes for u20-u25 can be found on Oracle's changelist blog. OpenJDK 7 can be enabled by configuring your pom.xml. Currently, only maven builds are supported with this update.

This update has no impact on any running applications. If you choose not to use this buildpack, your applications will continue to use OpenJDK 6u20.

Contents