Skip to content

Instantly share code, notes, and snippets.

View thedava's full-sized avatar

David S. thedava

View GitHub Profile
@thedava
thedava / minecraft_deploy.sh
Last active August 29, 2015 14:16
Minecraft-Server Deployment Script
#!/bin/bash
svn_path="http://davahome-minecraft.svn/trunk/MinecraftInstance/"
live_folder="minecraft_instance"
backup_folder="__minecraft_instance"
export_folder="__export"
echo "Exporting from svn: "${svn_path}
# Remove old export folder if exists
@thedava
thedava / color_echo.sh
Last active January 17, 2020 14:58
color_echo - Colored Bash echo output
# Reset
Color_None='\e[0m'
# Regular Colors
Color_Black='\e[0;30m'
Color_Red='\e[0;31m'
Color_Green='\e[0;32m'
Color_Yellow='\e[0;33m'
Color_Blue='\e[0;34m'
Color_Purple='\e[0;35m'
@thedava
thedava / zf2-ServiceListeners.md
Last active September 10, 2015 12:13
Zend2 Service Listeners

ZendFramework 2 Service Listeners

ServiceManager

  • Config Key: service_manager
  • Interface: Zend\ModuleManager\Feature\ProviderInterface

ControllerLoader

@thedava
thedava / PcntlFork.php
Created October 27, 2015 10:50
PHP fork wrapper class
<?php
/**
* A wrapper class for PHP fork functionality
*
* @author dava
* @since 2015-10-27
*/
class PcntlFork
{
@thedava
thedava / ImageGreyscaleExtension.cs
Created March 12, 2016 21:00
C# Greyscaler for images
using System.Drawing;
using System.Drawing.Imaging;
static class ImageGreyscaleExtension
{
/// <summary>
/// Returns the grey scaled image
/// </summary>
/// <param name="image"></param>
/// <returns></returns>
@thedava
thedava / InstanceDetector.cs
Created May 10, 2016 08:51
C# Instance Detection
using System.Diagnostics;
public class InstanceDetector
{
protected Process GetCurrentProcess()
{
return Process.GetCurrentProcess();
}
protected Process[] GetRunningProcesses()
@thedava
thedava / Hash.php
Last active January 9, 2021 20:10
Function to create a save hash for passwords (very hard to brute force)
<?php
/**
* The same logic as the function but as a class
*/
class Hash {
private const PASSWORD_ALGO = 'sha512'; // hash will have 128 chars
private const PASSWORD_SALT = 'change_me_pls'; // a static string
private const PASSWORD_CYCLES = 12345; // number between 10.000 and 20.000
private const PASSWORD_DIVERSITY = 3; // number greater than 2
@thedava
thedava / Brainfuck.php
Created July 25, 2016 16:10
PHP Brainfuck Converter
<?php
class Brainfuck
{
/**
* Returns the string a simple brainfuck sequence (only + and .)
*
* @param string $text
*
* @return string
@thedava
thedava / update_composer.sh
Created July 28, 2016 22:16
Update all composer.phar's in all subdirectories (self-update)
#!/bin/bash
find . -name "composer.phar" -type f -print0 | xargs -0 -i{} php {} self-update
@thedava
thedava / sol.php
Created October 29, 2016 13:14
A small PHP script for converting SOL (Mars days) into Earth days
<?php
/**
* Usage: php sol.php <amount of sols>
*
*/
date_default_timezone_set('UTC');
define('DAY_MARS', 3600 * 24 + 39 * 60 + 35); // 24h 39m 35s
define('DAY_EARTH', 3600 * 24);