Skip to content

Instantly share code, notes, and snippets.

View mstaack's full-sized avatar
🎯
Focusing

Max mstaack

🎯
Focusing
View GitHub Profile
@mstaack
mstaack / batch-strace.sh
Created April 20, 2016 19:00 — forked from hydra35/batch-strace.sh
strace all the php-fpm worker processes
#!/bin/bash
additional_strace_args="$1"
MASTER_PID=$(ps auwx | grep php-fpm | grep -v grep | grep 'master process' | cut -d ' ' -f 6)
while read -r pid;
do
if [[ $pid != $MASTER_PID ]]; then
nohup strace -r -p "$pid" $additional_strace_args >"$pid.trc" 2>&1 &
@mstaack
mstaack / RestControllerTrait.php
Created May 24, 2016 17:04 — forked from beanmoss/RestControllerTrait.php
Playing with Laravel Lumen: simple RESTful trait.
<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
trait RestControllerTrait
{
public function index()
{
$m = self::MODEL;
return $this->listResponse($m::all());
@mstaack
mstaack / Callback.php
Created January 17, 2017 22:19 — forked from wyrfel/Callback.php
Callback Helper to extend capabilities of php built-ins that allow passing of custom callback functions
<?php
namespace Wyrfel\Helper;
use Exception;
/**
* Callback helper
*
* This allows passing parameters to callbacks for php built-ins that take a callback
@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

@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 / 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 / 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 / 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).