Skip to content

Instantly share code, notes, and snippets.

View vegaasen's full-sized avatar
🤠
Howdy

Vegard Aasen vegaasen

🤠
Howdy
View GitHub Profile
@vegaasen
vegaasen / DaemonThread.java
Last active December 22, 2015 21:39
A simple DaemonThread class
public abstract class DaemonThread implements Runnable {
public static final TimedEvent DEFAULT = new TimedEvent();
private static final String DAEMON_THREAD_ID = "DaemonThread@selfdef";
private Thread thread;
private volatile boolean active;
private boolean daemon = true;
@vegaasen
vegaasen / chartUtils-useless
Created September 30, 2013 06:29
ChartUtils - working with the google-chart-tools
public final class ChartTools {
private static final String EMPTY = "";
private static final int HEIGHT = 300, WIDTH = 800;
private static final AxisStyle axisStyle = AxisStyle.newAxisStyle(Color.WHITE, 12, AxisTextAlignment.CENTER);
private ChartTools() {
}
public static String getLineChart(Map<String, List<Double>> input, final String title, final int days) {
@vegaasen
vegaasen / SetUtils.java
Last active December 27, 2015 01:29
SetUtils, simple utils in order to convert to sorted sets, and sets from list and array.
import java.lang.reflect.Array;
import java.util.*;
/**
* @author <a href="mailto:[email protected]">Vegard Aasen</a>
* @since 3:13 PM
*/
public final class SetUtils {
private static final String EMPTY = "";
@vegaasen
vegaasen / smallify.sh
Last active December 28, 2015 12:59
Simple sips script to convert multiple files in directories. This is just a script that I use in regards to uploading images to e.g forums or facebook. Only works on MAC (SIPS).
#!/bin/bash
# Simple script that performs SIPS-operations on mac. This script is created to simplify the actions in regards to sips, and also so that one dont have to
# remember what to do each time regarding the command I always tend to forget..duh..
# ENjoi!
#
# @version 0.1b
# @author vegaasen
# @since 16.11.2013
#!/bin/bash
#
# @author <a href="[email protected]">Vegard Aasen</a>
# @version 0.1
host=$1;
allPorts=$2;
ports="";
@vegaasen
vegaasen / ConnectionCustomizer
Created April 23, 2014 10:32
c3p0 connectionCustomizer implementation example
..
..
..
dataSource = new ComboPooledDataSource();
dataSource.setConnectionCustomizerClassName(SchemaConnectionCustomizer.class.getSimpleName());
..
..
..
public class SchemaConnectionCustomizer extends AbstractConnectionCustomizer {
@vegaasen
vegaasen / TelnetUtils.java
Last active August 29, 2015 14:00
TelnetUtils
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
package com.telenor.security.sso.api.service.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Vegard Aasen</a>
* @since 21:38
*/
@vegaasen
vegaasen / LogbackProgramatically.java
Last active August 29, 2015 14:01
Simple configuration for logback programatically configuration
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.FileAppender;
public class Loggerutils {
package com.vegaasen.playhouse.cert.run;
import com.telenor.sec.certificate.cert.CertificateUtils;
import com.telenor.sec.certificate.common.CertificateProperties;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSocketFactory;
import java.io.IOException;
import java.net.URL;
import java.security.cert.Certificate;