Skip to content

Instantly share code, notes, and snippets.

View mstaack's full-sized avatar
🎯
Focusing

Max mstaack

🎯
Focusing
View GitHub Profile
@mstaack
mstaack / scan_del.sh
Created October 18, 2017 17:31 — forked from itamarhaber/scan_del.sh
A bash script that deletes Redis keys by pattern using SCAN
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Delete keys from Redis matching a pattern using SCAN & DEL"
echo "Usage: $0 <host> <port> <pattern>"
exit 1
fi
cursor=-1
@mstaack
mstaack / twitter.html
Created November 7, 2017 10:00 — forked from Radostin/twitter.html
Twitter Mockup with TailwindCSS
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Twitter</title>
<link rel="stylesheet" type="text/css" href="./css/tailwind.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
@mstaack
mstaack / ParensParser.php
Created November 22, 2017 13:28 — forked from xeoncross/ParensParser.php
PHP: Nested Parenthesis Parser
<?php
// @rodneyrehm
// http://stackoverflow.com/a/7917979/99923
class ParensParser
{
// something to keep track of parens nesting
protected $stack = null;
// current level
protected $current = null;
@mstaack
mstaack / inline.html
Created December 18, 2017 13:41
inline image html
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><img src="data:image/image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAIAAADajyQQAAAAhnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjadY5LCsNADEP3c4oewb+R7eOUkEBv0OPXZpKmm76FLIQRGvv7dYxHwyTDpgcSoMLSUp5lghZKxELct3RxXuVycsdDZRlkONn9aGd+MRWBw80dExs2qXbZlTVKu6hbqWfkT8l30Z/8WvEBQsUsKBcOhtYAAAoCaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/Pgo8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA0LjQuMC1FeGl2MiI+CiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICBleGlmOlBpeGVsWERpbWVuc2lvbj0iNzIiCiAgIGV4aWY6UGl4ZWxZRGltZW5zaW9uPSI3MiIKICAgdGlmZjpJbWFnZVdpZHRoPSI3MiIKICAgdGlmZjpJbWFnZUhlaWdodD0iN
@mstaack
mstaack / gist:599a28114ceecc45e8f5f6d93f7b7d71
Created December 18, 2017 13:42
image inline with new line
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><img src="data:image/image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAIAAADajyQQAAAAhnpUWHRSYXcgcHJvZmlsZSB0
eXBlIGV4aWYAAHjadY5LCsNADEP3c4oewb+R7eOUkEBv0OPXZpKmm76FLIQRGvv7dYxHwyTD
pgcSoMLSUp5lghZKxELct3RxXuVycsdDZRlkONn9aGd+MRWBw80dExs2qXbZlTVKu6hbqWfk
@mstaack
mstaack / database-quick-reference.md
Created March 10, 2018 01:01
Database Quick Reference

Designing a database

Schema Naming Conventions

  • Tables: english, lower_snake_case and plural.
  • Columns: english, lower_snake_case and singular.
  • Don't use reserved words
  • Every table must contain a auto increment primary key 'id' int(11)
  • Foreign key names must be unique per database. Format: sourcetable_sourcefield_destinationtable_destinationfield
  • The name of an index should match the field name. Multiple fields can be combined with _ (underscore).
@mstaack
mstaack / chunked-transfer-encoding-with-the-slim-framework.md
Created March 10, 2018 01:06
Emitting stream responses with Slim

Emitting stream responses with Slim

What is Chunked transfer encoding?

Chunked transfer encoding is a streaming data transfer mechanism available in version 1.1 of the Hypertext Transfer Protocol (HTTP). In chunked transfer encoding, the data stream is divided into a series of non-overlapping "chunks". The chunks are sent out and received independently of one another. No knowledge of the data stream outside the currently-being-processed chunk is necessary for both the sender and the receiver at any given time.

Read more

Implementing a chunked response with a PSR-7 implementation is a quite complex task.

@mstaack
mstaack / imagick-3.4.0-PHP7-forge.sh
Created March 15, 2018 14:26 — forked from pascalbaljet/imagick-3.4.0-PHP7-forge.sh
Install Imagick 3.4.0 on PHP 7.0 server (Laravel Forge)
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
@mstaack
mstaack / implementing-php-web-applications.md
Created March 23, 2018 23:23
Modularisierung von Web Applikationen (PHP)

Modularisierung von Web Applikationen

Einleitung

Ziel des Dokuments ist es, mögliche Wege zur Trennung von Daten und Geschäftslogik aufzuzeigen und diese anhand von praktischen Beispielen zu untermauern. Desweiteren sollen Konventionen und Best Practices die Teamarbeit verbessern, die Produktivtät erhöhen und die Einarbeitungszeit reduzieren.

Folgende Fragen sollten beantwortet werden:

  • Wann und wo trennen wir was wie und warum. (Beispiele)
  • Wo möglich bzw. sinnvoll bitte generelle oder spezifische Aussagen für unsere CakePHP 2.x und 3.x Applikationen machen.
@mstaack
mstaack / siege
Created June 14, 2018 08:11 — forked from MikeNGarrett/siege
Siege with JSON POST data
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json'
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'