Skip to content

Instantly share code, notes, and snippets.

View firegate666's full-sized avatar

Marco Behnke firegate666

View GitHub Profile
@firegate666
firegate666 / switchingTimezone.java
Last active April 16, 2021 12:49
Change time to another timezone
// get now date
LocalDateTime ldt = LocalDateTime.now();
// tell him that this is Europe/Berlin
ZonedDateTime serverTime = ldt.atZone(ZoneId.of("Europe/Berlin"));
// then tell him to the same time but in another zone
ZonedDateTime playerTime = serverTime.withZoneSameInstant(ZoneId.of("UTC"));
System.out.println(serverTime);
System.out.println(playerTime);
@firegate666
firegate666 / Fastfile
Last active June 8, 2021 08:36
Example of how to upload app previews from an ordered structure the apple app store by using Fatland and Spaceship
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
@firegate666
firegate666 / createBundle.sh
Created November 24, 2017 00:43
Shell helper to create the bundle crt file needed by nginx
#/bin/bash
if [ -z "$1" ]; then
myyear=`date +'%Y'`
echo "Please specifiy domain by calling e.g.: './createBundle.sh mydomain.com $myyear'"
exit -4
fi
if [ -z "$2" ]; then
myyear=`date +'%Y'`
@firegate666
firegate666 / IPAnonimizer.scala
Created March 1, 2017 12:06
IP anonimizer written in scala for IPv4 and IPv6
class IP(userIp: String) {
def get: String = userIp
def getAnonimized: String = {
if (userIp.contains(":")) {
anonimizeIpV6(userIp)
} else if (userIp.contains(".")) {
anonimizeIpV4(userIp)
} else {
@firegate666
firegate666 / accordion.ts
Created September 9, 2016 08:47
TypoScript Accordion Menu with Bootstrap CSS
# HTML part
#<div class="panel-group" id="accordion">
# <f:cObject typoscriptObjectPath="lib.menu2" />
#</div>
# TypoScript part
lib.menu2 = HMENU
lib.menu2 {
wrap = |
@firegate666
firegate666 / fizz_buzz_configurable.php
Last active December 27, 2015 00:59
This is a free configurable implementation of the fizzbuzz problem
<?php
$config = array(
'fizz' => 3,
'buzz' => 5,
/*
'prim' => function($num) {
return in_array($num, array(1, 2, 3, 5, 7, 11, 13, 17, 19, 23));
}
*/
);
@firegate666
firegate666 / php override return with finally.php
Created October 29, 2013 20:00
Funny behaviour where you can override the return value of a method in finally
<?php
function blabla() {
try {
echo "try";
return 1;
} catch (Exception $e) {
echo "catched";
return 4;
} finally {
print "finally";
@firegate666
firegate666 / reflect.php
Created February 8, 2012 14:12
magic property getter example with internal xml storage
<?php
/**
* Example class that holds an xml and adds magic getter and property accessors for xml nodes
* The class property annotations define type casts
*
* @property integer username
* @property string password
* @property array collection
* @property array car
*
@firegate666
firegate666 / file_cache_control.php
Created December 8, 2011 13:50
Calculate etag and last-modified for given file and send not-modified since header
<?php
/**
* class for cache control
*/
final class CacheControl
{
private function __construct()
{
// no instances
@firegate666
firegate666 / foreach_ext.php
Created November 22, 2011 10:35
extended foreach method with extra information about first and last elements, number of elements, actual index
<?php
/**
* Call callback function for every element of an array and provide some extra information for each element
*
* @param array $array
* @param Callback/Closure $callback
* Callback/Closure must have 6 parameters
* mixed key: key of item
* mixed value: value of item
* integer counter: human readable index of item; starts with 1