Skip to content

Instantly share code, notes, and snippets.

@eirikbakke
eirikbakke / gist:1069036
Created July 7, 2011 07:19
The VideoDatabase Class
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
public class VideoDatabase {
public static List<Video> loadVideos() throws SQLException {
throw new UnsupportedOperationException("TODO: Implement when instructed.");
}
public static void insertVideo(Video v) throws SQLException {
@eirikbakke
eirikbakke / gist:1074542
Created July 10, 2011 13:40
The DatabaseConnector class.
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public final class DatabaseConnector {
private static DatabaseConnector instance;
private static String useMySQL = null;
// Deployment note: Replace with a real server name.
/*
The MIT License (MIT)
Copyright (c) 2015 Eirik Bakke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@eirikbakke
eirikbakke / LexerInputCharStream.java
Last active October 27, 2015 19:56
Updated LexerInputCharStream to avoid Guava dependency.
/*
The MIT License (MIT)
Copyright (c) 2015 Eirik Bakke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
--- a 2013-02-19 20:50:11.000000000 -0500
+++ b 2013-02-19 20:50:04.000000000 -0500
@@ -1 +1 @@
-Angela teaches a FOB the pinky-swear.
+Samples teaches a FOB the pinky-swear.
package com.sieuferd.uiutil;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import javax.swing.*;
public final class ScrollpaneTrackpadJitterBugExhibit extends JFrame {
private static final class ViewportPanel extends JPanel implements Scrollable {
public ViewportPanel() {
@eirikbakke
eirikbakke / panama.sql
Created May 10, 2016 03:31
Panamapapers PostgreSQL import script
-- PostgreSQL import script for panamapapers CSV files available from https://panamapapers.icij.org/blog/20160509-offshore-database-release.html
-- First convert CSV files from MacRoman to UTF-8 encoding:
-- iconv -f MACROMAN -t UTF-8 Entities.csv > Entities-utf8.csv
-- iconv -f MACROMAN -t UTF-8 Addresses.csv > Addresses-utf8.csv
-- iconv -f MACROMAN -t UTF-8 Intermediaries.csv > Intermediaries-utf8.csv
-- iconv -f MACROMAN -t UTF-8 Officers.csv > Officers-utf8.csv
-- iconv -f MACROMAN -t UTF-8 all_edges.csv > all_edges-utf8.csv
drop table if exists addresses cascade;
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
/**
* Measure the performance on both LineBreakMeasurer and Font.layoutGlyphVector for short strings.
package com.eirikbakke.upstream.popup;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
public class PrintGC {
public static final void main(String args[]) {
System.out.println(System.getProperty("java.version"));
for (GraphicsDevice graphicsDevice :
@eirikbakke
eirikbakke / SVGBenchmark.java
Created June 7, 2019 02:52
SVG vs. PNG loading benchmark
import com.google.common.collect.ImmutableSet;
import com.google.common.math.StatsAccumulator;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Set;
import javax.imageio.ImageIO;