Skip to content

Instantly share code, notes, and snippets.

View shakahl's full-sized avatar
:electron:

Soma Szelpal shakahl

:electron:
  • Platform whisperer @ Shakahl Ltd. • Made GitLab AutoDevOps work on GitHub • DevOps’d the hell out of DiNG • Metaverse pipelines @ nextearth.io • Used to scrub fraud on Jasmin at Docler
  • Budapest, Hungary
  • 05:55 (UTC +01:00)
  • LinkedIn in/somaszelpal
  • X @szelpalsoma
  • Facebook szelpalsoma
  • Instagram szelpalsoma
View GitHub Profile
@shakahl
shakahl / MAMP_Dynamic_Virtual_Hosts.md
Created April 19, 2017 17:55
Simplify Local Development with MAMP & DNSMASQ (& XIP.io)

Simplify Local Development with MAMP & DNSMASQ

When you sit down and start a new project, often times, you'll want to set up a virtual host, a spoof domain that will emulate a live environment. The effort is usually two parts: set up a domain in /etc/hosts, and then add a <VirtualHost> entry in /Applications/MAMP/conf/apache/httpd.conf to make your files accessible.

This tutorial is setting up a 'zero-configuration' development environment. We'll be setting up a spoof domain ending in .dev. In MAMP, we'll create a folder called dev. Any folder inside, the name will become the domain.

@shakahl
shakahl / get_row_combinations.php
Created May 19, 2017 11:57
Function to calculate the combinations of associative arrays.
<?php
if (!function_exists('get_row_combinations')) {
/**
* @param array $arrays
*/
function get_row_combinations($arrays)
{
$result = [[]];
@shakahl
shakahl / auth.lua
Created June 21, 2017 08:49 — forked from fur-q/auth.lua
nginx rtmp/hls server setup
-- add users:
-- $ htpasswd -s -c /etc/nginx-rtmp/.htpasswd streamname
-- stream:
-- $ ffmpeg -i foo.mp4 -c copy -f flv rtmp://abc.de/streamname?auth=password
local users = {}
for line in io.lines("/etc/nginx-rtmp/.htpasswd") do
local user, pass = line:match("([^:]+):{SHA}([^\n]+)")
users[user] = pass
end
@shakahl
shakahl / API.md
Created August 8, 2017 07:52 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@shakahl
shakahl / graceful.go
Created September 20, 2017 12:21 — forked from peterhellberg/graceful.go
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@shakahl
shakahl / Makefile
Created September 20, 2017 12:21 — forked from turtlemonvh/Makefile
Golang Project Makefile Template
# Borrowed from:
# https://github.com/silven/go-example/blob/master/Makefile
# https://vic.demuzere.be/articles/golang-makefile-crosscompile/
BINARY = superdo
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GOARCH = amd64
VERSION?=?
@shakahl
shakahl / NewMessage.php
Created September 20, 2017 12:21 — forked from sebastiaanluca/NewMessage.php
Laravel + Redis + NodeJS + Socket.io pub/sub secure server and client supporting multiple rooms, channels, users, … Add `client.js` to your client app, run `node server.js`, and trigger the Laravel event any way you want to broadcast the data.
<?php
namespace App\Events;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Queue\SerializesModels;
class NewMessage extends Event implements ShouldBroadcast
{
@shakahl
shakahl / STokenDownload.php
Last active September 7, 2021 07:24
PHP - File downloader implementation with url token-based authentication and token expiration. #php #auth #token #file #download #class #library
<?php
namespace ST;
/**
* STokenDownload
*/
class STokenDownload
{
/**
@shakahl
shakahl / WebSocketController.php
Last active September 7, 2021 07:23 — forked from Mevrael/WebSocketController.php
PHP - Laravel websocket (Ratchet/ReactPHP) integration #php #async #websocket #laravel #reactphp #asynchronous #hack
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session;
use Ratchet\WebSocket\Version\RFC6455\Connection;
@shakahl
shakahl / index.js
Created February 27, 2018 11:34 — forked from yandzee/index.js
Code retry with promises
// Author: Renat Tuktarov (renat@sourcerer.io)
const retry = function(fn, prev) {
return new Promise((current, reject) => {
const resolve = _ => (prev && prev()) || current();
fn(resolve, delay => {
setTimeout(_ => {
retry(fn, resolve);
}, delay);