Skip to content

Instantly share code, notes, and snippets.

View mstaack's full-sized avatar
🎯
Focusing

Max mstaack

🎯
Focusing
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / assignSlots.sh
Created October 12, 2017 10:02 — forked from jpe42/assignSlots.sh
Evenly assign slots to a new Redis Cluster
#!/bin/bash
#./assignSlots.sh 7001 5 redis-cluster-m-
readonly STARTING_PORT=${1:-0}
readonly NUM_MASTERS=${2:-0}
readonly NAME_PREFIX=${3:-"redis-cluster-m-"}
readonly MAX_SLOT=$((16383))
readonly SLOT_RANGE=$(((MAX_SLOT + NUM_MASTERS - 1) / NUM_MASTERS))
readonly LOCAL_CONTAINER_ID=$(docker ps -f name="$NAME_PREFIX" -q | head -n 1)
readonly LOCAL_PORT=$(docker inspect --format='{{index .Config.Labels "com.docker.swarm.service.name"}}' "$LOCAL_CONTAINER_ID" | sed 's|.*-||')
for ((port = STARTING_PORT, endPort = STARTING_PORT + NUM_MASTERS, slot = 0; port < endPort; port++)) do
@mstaack
mstaack / Application.php
Last active October 7, 2017 10:05 — forked from deividaspetraitis/Application.php
Lumen Custom Request
<?php namespace App;
class Application extends \Laravel\Lumen\Application
{
use Concerns\RoutesRequests; // override with our new trait
}
@mstaack
mstaack / readme.md
Created July 18, 2017 21:15 — forked from endolith/readme.md
How to stream a webcam to a web browser in Ubuntu

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion

~> nano ~/.motion/motion.conf