Skip to content

Instantly share code, notes, and snippets.

View mihaeu's full-sized avatar
💭
🏳️‍🌈

Michael Haeuslmann mihaeu

💭
🏳️‍🌈
View GitHub Profile
@mihaeu
mihaeu / gist:aae8aa7c5450f6b8552d
Last active August 29, 2015 14:12
Create a nice program structure for the current Windows user [XP/7/8]
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\AUDIO"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\DESIGN"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\GAMES"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\INTERNET"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MISC"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\OFFICE"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\SYSTEM"
mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\VIDEO"
@mihaeu
mihaeu / OnlineShopper
Created June 3, 2015 11:19
Compares and finds the cheapest options for online shopping (prices, shipping, vouchers).
<?php
// Online - Shops
// --------------
//
// NOTE:
// - Shipping costs conditions must be valid PHP expressions.
// - Prices must be integers with the decimals included, so 5.00 becomes 500.
// - The shipping cost conditions have to be ordered from lowest to greatest, otherwise computation will be wrong.
//
@mihaeu
mihaeu / print-php-scripts.sh
Created January 3, 2016 17:18
work in progress ... I'll be using this to print the source code of my live coding exam at university
author="Michael Haeuslmann"
path='/home/mike/workspace/pw-online-auction/'
save_path='\/home\/mike\/workspace\/pw-online-auction\/'
output="test.pdf"
printf "# Prüfung Professionelle Webentwicklung\n\nAuthor: $author\n\nDatum: `date`\n\n" > test.md
find $path -type f -name '*.php' -print0 | while IFS= read -r -d '' file; do
printf '%s\n' "$file"
printf "##" >> test.md
echo $file | sed "s/$save_path//" >> test.md
# Shortcuts
Actions: Ctrl + Shift + A
Search everywhere: 2x Shift
Next occurence: Alt + J
Local insert: Alt + Insert
Create file: Ctrl + Alt + Insert
Open class: Ctrl + N
Run: Shift + F10
Extract method: Ctrl + Alt + M
<?php declare(strict_types = 1);
class XCollection implements Countable, IteratorAggregate
{
/**
* @var X[]
*/
private $x;
public function __construct()
<?php declare(strict_types = 1);
class XCollection implements Countable, IteratorAggregate
{
/**
* @var SplObjectStorage
*/
private $x;
public function __construct()
// *************************************************
// include jQuery and lightbox2
// *************************************************
/*!
* jQuery JavaScript Library v2.1.4
* http://jquery.com/
*
* Includes Sizzle.js
/* Preload images */
body:after {
content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAC6CgRnAAAAPFBMVEX///8AAAD9/f2CgoKAgIAAAAAAAAAAAABLS0sAAAAAAACqqqqqqqq6urpKSkpISEgAAAC7u7u5ubn////zbsMcAAAAE3RSTlMASv6rqwAWS5YMC7/AyZWVFcrJCYaKfAAAAHhJREFUeF590kkOgCAQRFEaFVGc+/53FYmbz6JqBbyQMFSYuoQuV+iTflnstI7ssLXRvMWRaEMs84e2uVckuZe6knL0hiSPObXhj6ChzoEkIolIIpKIO4joICAIeDd7QGIfCCjOKe9HEk8mnxpIAup/F31RPZP9fAG3IAyBSJe0igAAAABJRU5ErkJggg==) url(data:image/gif;base64,R0lGODlhIAAgAPUuAOjo6Nzc3M3Nzb+/v7e3t7GxsbW1tbu7u8XFxdHR0djY2MHBwa2trbm5ucnJyaSkpKWlpaGhoeLi4urq6u7u7ubm5vLy8vb29vT09Pr6+v39/aysrK+vr7Ozs8fHx9vb297e3qmpqb29vdPT06amptXV1aCgoMvLy8/Pz9fX18PDw/j4+Ozs7ODg4PDw8KioqOTk5JqampmZmZycnP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJBwAuACwAAAAAIAAgAEAG/0CXcEgECQ6bUGRDbDpdimTo9QoJnlhsYVvojLLgrEAkGiwWiFTYldGsRyHSYz6P2COG9XCw2TAYeXprCQYEhQcKgoouAQ4IHg4CAiMpCiASFRMUFhgXFxkZawEDcnd2Jh2LLiAdLyQvELEFX6pCAQx9fQ21T1wFHCi8TwcGxQYnwk8eBAcHZQnJTh8D1I8OJwmWMBMsFJudoG4u4mAgIwIoCSMKlpjcm
@mihaeu
mihaeu / check-code-cov.sh
Last active June 2, 2016 06:49
Bash script to insure that your code coverage is above a certain limit (e.g. for the CI server or pre-commit hook)
#!/usr/bin/env bash
# This is just a quick hack to determine if the code coverage
# is enough or not. Change the path to PHPUnit if needed.
#
# @author Michael Haeuslmann <haeuslmann@gmail.com>
NO_COLOR='\x1b[0m'
OK_COLOR='\x1b[32;01m'
ERROR_COLOR='\x1b[31;01m'
package ro.inf.prg2.uebung06.loesung;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.*;
/**
* =======================================================
* Singleton Pattern & Testing
* =======================================================