Skip to content

Instantly share code, notes, and snippets.

@BlackScorp
BlackScorp / server.bat
Created April 20, 2017 08:13
Batch files to start maria db
start %~dp0bin/mysqld.exe --datadir=%~dp0data --console
exit
@BlackScorp
BlackScorp / calculator.php
Created July 27, 2017 09:13
Basic OOP Composition over inheritance example
<?php
error_reporting(-1);
ini_set('display_errors', true);
abstract class CalculatorFactory
{
public static function create($string, $value)
{
$className = ucfirst($string) . 'Calculator';
if (!class_exists($className)) {
<?php
$width = 800;
$height = 800;
$centerX = $width / 2;
$centerY = $height / 2;
$img = imagecreate($width, $height);
$backgroundColor = imagecolorallocate($img, 220, 220, 220);
$orange = imagecolorallocate($img, 255, 165, 0);
$black = imagecolorallocate($img, 0, 0, 0);
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME) !-d
RewriteRule ^ index.php [L,QSA]
</IfModule>
@BlackScorp
BlackScorp / autoload.php
Last active December 27, 2020 17:55
Code zum Youtube Video https://youtu.be/wK6AVvO-rAI
<?php
$rootDir = __DIR__.'/classes/';
$autoload = function($className) use($rootDir){
$fileName = '';
if($lastNameSpacePosition = strpos($className,'\\')){
$namespace = substr($className, 0,$lastNameSpacePosition);
$className = substr($className,$lastNameSpacePosition+1);
$fileName = str_replace('\\',DIRECTORY_SEPARATOR,$namespace).DIRECTORY_SEPARATOR;
@BlackScorp
BlackScorp / export.php
Last active August 21, 2019 20:33
Beispiel Code für das Youtube Video https://youtu.be/vE7AXqs2dKk
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
$array = [
['Row 1','Row 2','Row 3'],
['Col 1','Col 2','Col 3'],
['Col 1','Col 2','Col 3'],
];
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
function render(string $path,array $data){
if(!is_file($path)){
trigger_error('Datei "'.$path.'" wurde nicht gefunden');
return null;
}
@BlackScorp
BlackScorp / Template.php
Created September 5, 2019 16:00
Code for the Youtube Tutorial https://youtu.be/g-rUVNo0FWc
<?php
function render(string $path, array $data) {
if (defined('TEMPLATE_DIR')) {
$path = TEMPLATE_DIR . DIRECTORY_SEPARATOR . $path;
}
if (!is_file($path)) {
trigger_error('Datei "' . $path . '" wurde nicht gefunden');
return null;
<?php
function event(string $name, array $data = [],callable $action = null,int $priority = 0){
static $events = [];
if($action){
$events[$name][]=[
'priority' => $priority,
'action' => $action
];
return null;
}
@BlackScorp
BlackScorp / index.php
Created September 18, 2019 19:20
Code for the Youtube Tutorial https://youtu.be/1kRy0JgPC04
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
$url = 'https://www.green-secure.de/podcast/';
$domDocument = new DOMDocument();