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 / gitShortcutsAndCommands.sh
Last active August 29, 2015 14:03
Simple GIT Commands/Shortcuts
#!/bin/sh
##
## Simple GIT Commands
##
# Branch Overview
echo "Adding branch overview. Use git bo to see it in action";
git config --global alias.boja 'log --all --graph --decorate=short --pretty=format:"%C(yellow bold)%h%C(white)% an%C(auto): (%ar)%+d"';
git config --global alias.bojaa 'log --pretty --format="%C(green)%ce @ -- %C(yellow)%ar -- %C(white)%h %C(blue)%s" --graph --all';
@vegaasen
vegaasen / AsyncHandling.java
Last active August 29, 2015 14:03
Asynchronous interface
public interface AsyncHandler {
<T> Future<T> submit(Callable<T> callable);
}
public class AsyncHandlerImpl implements AsyncHandler {
private static final int NUM_THREADS = 5;
/* USING EXECUTORS (java 1.6) */
private ExecutorService pool = Executors.newFixedThreadPool(NUM_THREADS);
/* USING EXECUTORS (java 1.7) */
private final ForkJoinPool pool = new ForkJoinPool(NUM_THREADS);
@Override
@vegaasen
vegaasen / git-cheat-sheet.md
Last active December 19, 2025 17:01
My everyday git commands cheat-sheet :-)

Introduction

Day2Day stuff related to git :-). Not the biggest nor the most advanced one.

Error-cases

fatal: No annotated tags can describe

Due to the commit reference not found on describe in any tags (weird)

package com.telenor.runners;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import java.util.concurrent.atomic.AtomicInteger;
@vegaasen
vegaasen / StopWatch.java
Created September 8, 2014 08:33
StopWatch - simple stopwatch-thingie
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* Simple Stopwatch implementation in order to measure ..things.
*
* @author <a href="mailto:[email protected]">Vegard Aasen</a>
* @since 8:30 PM
*/
public final class StopWatch {
@vegaasen
vegaasen / SystemInformationUtils.java
Created September 23, 2014 12:30
SystemInformationUtils for Java
/**
* @author <a href="[email protected]">vegard.aasen/t769765</a>
*/
public final class SystemInformationUtils {
private SystemInformationUtils() {
}
public synchronized static SystemInformation getCurrentSystemInformation() {
final SystemInformation systemInformation = new SystemInformation();
@vegaasen
vegaasen / Password.java
Created September 30, 2014 05:21
Proposed implementation of (as-safe-as it-gets) passwords in java.
import java.util.Objects;
/**
* Password-class which is as safe as it gets in Java. Try to avoid using the "toString", "fromString"-methods due to
* memory allocations and gc-troubles (in regards to the actual removal of the password within RAM etc.
*
* @author <a href="mailto:[email protected]">Vegard Aasen</a>
*/
public final class Password implements CharSequence, Comparable<Password> {
@vegaasen
vegaasen / maven-deployer-pom.xml
Created October 15, 2014 07:11
Simple maven deployer to be used within Jenkins
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vegaasen.app</groupId>
<artifactId>app-maven-deployer-local</artifactId>
<version>1.0-SNAPSHOT</version>
<name>cool-app-maven-deployer</name>
<description>
This pom-file uses the maven-antrun-plugin to be able to execute unix-commands within a pom.xml.
@Test
public void misc() {
final SimpleDocumentBuilderHolder documentBuilderHolder = new SimpleDocumentBuilderHolder();
ExecutorService exec = Executors.newFixedThreadPool(10);
for (int i = 0; i < ROUNDS; i++) {
exec.submit(new Runnable() {
public void run() {
try {
final DocumentBuilder builder = documentBuilderHolder.allocateDocumentBuilder();
@vegaasen
vegaasen / ssl-request.cs
Last active August 29, 2015 14:07
http-ssl-request with sslv3 and tlsv1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Security.Authentication;
using System.Net.Sockets;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;