Skip to content

Instantly share code, notes, and snippets.

View sgohl's full-sized avatar

sgohl sgohl

  • Dresden, Saxony, Germany
View GitHub Profile
@sgohl
sgohl / wrap setuid binary
Created July 24, 2019 20:40
wrap setuid binary
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
setuid( 0 );
system( "/path/to/binary" );
return 0;
map $http_user_agent $is_mobile {
default 1;
~*android|mobile|windows\s+(?:ce|phone) 1;
~*spider|crawl|slurp|bot 0; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 0;
}
if ($is_mobile) { proxy_set_header IS_MOBILE 1; }
@soundstorm
soundstorm / livechatws.py
Last active April 27, 2018 15:56
Public channel for Rocket.Chat without registration
#!/usr/bin/env python
ws_port = 8000 # public [e.g. via proxy]
http_port = 8001 # just locally accessible
guest_identifier = ' [GUEST]'
incoming_url = 'https://example.org/hooks/token'
# First message to websocket will be the username, all afterwards will be sent to all connected WebSocket clients and Rocket.Chat
# Install SimpleWebSocketServer:
@juris
juris / redis-cluster-backup.sh
Last active March 21, 2023 14:27
Redis Cluster backup script
#!/bin/sh
readonly cluster_topology=$(redis-cli -h redis-cluster cluster nodes)
readonly slaves=$(echo "${cluster_topology}" | grep slave | cut -d' ' -f2,4 | tr ' ' ',')
readonly backup_dir="/opt/redis-backup"
mkdir -p ${backup_dir}
for slave in ${slaves}; do
master_id=$(echo "${slave}" | cut -d',' -f2)
@jdeathe
jdeathe / php-cachetool-usage.md
Last active January 11, 2023 23:46
How to Clear PHP Opcache without Restarting PHP-FPM.

PHP CacheTool - Manage cache in the CLI

Use CacheTool to view stats for and manage PHP's APC or Zend Opcache opcode cache.

Using CacheTool you can clear the PHP opcache without reloading PHP-FPM.

In this example, CacheTool is to be installed alongside a demonstration PHP-FPM Docker container.

Prerequisites

@josegonzalez
josegonzalez / redis_migrate.py
Last active April 25, 2024 02:34 — forked from iserko/redis_migrate.py
A simple script to migrate all keys from one Redis to another
#!/usr/bin/env python
import argparse
import redis
def connect_redis(conn_dict):
conn = redis.StrictRedis(host=conn_dict['host'],
port=conn_dict['port'],
db=conn_dict['db'])
return conn
@onimenotsuki
onimenotsuki / .i3status.conf
Last active April 26, 2022 10:01
Configuration files for i3wm in manjaro
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = yes
@cherti
cherti / alert.sh
Created December 9, 2016 13:47
send a dummy alert to prometheus-alertmanager
#!/bin/bash
name=$RANDOM
url='http://localhost:9093/api/v1/alerts'
echo "firing up alert $name"
# change url o
curl -XPOST $url -d "[{
\"status\": \"firing\",
@BretFisher
BretFisher / docker-swarm-ports.md
Last active June 11, 2024 14:06
Docker Swarm Port Requirements, both Swarm Mode 1.12+ and Swarm Classic, plus AWS Security Group Style Tables

Docker Swarm Mode Ports

Starting with 1.12 in July 2016, Docker Swarm Mode is a built-in solution with built-in key/value store. Easier to get started, and fewer ports to configure.

Inbound Traffic for Swarm Management

  • TCP port 2377 for cluster management & raft sync communications
  • TCP and UDP port 7946 for "control plane" gossip discovery communication between all nodes
  • UDP port 4789 for "data plane" VXLAN overlay network traffic
  • IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option

AWS Security Group Example

@davidjb
davidjb / webhook.py
Created February 3, 2016 23:42
Simple webhook endpoint for accepting requests to trigger a git update
from bottle import route, run, response, request, redirect
import os
import subprocess
@route('/', method="POST")
@route('/')
def main():
os.chdir('/opt/example-org-pages')
return_code = subprocess.check_call('git pull', shell=True)
if return_code == 0: