Skip to content

Instantly share code, notes, and snippets.

View nitschmann's full-sized avatar

Florian Nitschmann nitschmann

  • solarisBank AG
  • Germany
View GitHub Profile
@nitschmann
nitschmann / date_in.java
Created May 7, 2014 19:06
Java functions to get the date in N days
import java.util.Calendar;
import java.util.Date;
public Date dateIn(int days) {
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, days);
cal.set(Calendar.MINUTE, 0);
@nitschmann
nitschmann / ajax.js
Created July 21, 2014 10:33
Basic ajax handler function in JavaScript without jQuery
function ajax(url, method, data, async) {
method = typeof method !== 'undefined' ? method : 'GET';
async = typeof async !== 'undefined' ? async : false;
if (window.XMLHttpRequest) {
var xhReq = new XMLHttpRequest();
}
else {
var xhReq = new ActiveXObject('Microsoft.XMLHTTP');
}
@nitschmann
nitschmann / rmagick_2-12-2_mavericks.sh
Created July 23, 2014 10:06
Shell script to install Ruby rmagick -v '2.12.2' Gem with Homebrew under Mac OS X Mavericks
# This is a quick and dirty script for Max OS X Mavericks to install
# the Ruby rmagick Gem (Version 2.12.2) correct with Homebrew and ImageMagick
# Uninstall current ImageMagick (if installed)
if brew list -1 | grep -q "imagemagick"; then
brew uninstall imagemagick --force
fi
# Get all versions of ImageMagick via Homebrew
brew versions imagemagick
@nitschmann
nitschmann / fractionArithmetic.java
Created March 27, 2012 07:39
A class for easy fractions in Java
/**
*
* @author Florian Nitschmann
* @version 1.0
*/
public class fractionArithmetic {
/*
* Variablen für den Bruch (Zähler und Nenner)
*
@nitschmann
nitschmann / Interface.java
Created March 27, 2012 19:39
Heron-Verfahren
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* Interface.java
*
* Created on 27.03.2012, 21:01:59
*/
@nitschmann
nitschmann / QuickSort.java
Created September 28, 2012 16:44
JAVA class to sort numeric arrays
/**
* Easy JAVA class to sort numeric arrays
*
* @author Florian Nitschmann (f.nitschmann@googlemail.com)
* @version 0.1
*/
public class QuickSort {
/*
* void sort - Sort an numeric array
@nitschmann
nitschmann / LinarlySearch.java
Created October 14, 2012 20:55
Java method for linearly search
static int linearlySearch(int[] field, int searchIndex) {
for (int i = 0; i < field.length; i++)
if (field[i] == searchIndex)
return i;
return -1; // -1 no valid index
}
@nitschmann
nitschmann / BinaereSuche.java
Created October 14, 2012 21:00
Methode zur binären Suche in Java
public static int binaereSuche(int[] feld, int x)
{
int unten=0, mitte=0, oben=feld.length;
while (unten<oben)
{
mitte=(unten+oben)/2;
if (feld[mitte]==x)
{
return mitte+1;
}
@nitschmann
nitschmann / ArrayMultiUnique.php
Created October 23, 2012 09:54
PHP function to clean double entries multidimensional arrays
public function array_multi_unique($multiArray){
$uniqueArray = array();
foreach($multiArray as $subArray) {
if(!in_array($subArray, $uniqueArray)) {
$uniqueArray[] = $subArray;
}
}
return $uniqueArray;
}
@nitschmann
nitschmann / potenz.java
Last active December 17, 2015 19:49
Simple recursive function for potency in Java
int potency(int basis, int exponent) {
if(exponent == 1) return basis;
else return this.potenz(basis, exponent-1)*basis;
}