Skip to content

Instantly share code, notes, and snippets.

View kamermans's full-sized avatar
😏

Steve Kamerman kamermans

😏
View GitHub Profile
@ralph-tice
ralph-tice / gist:bc8f66c4fe1d4238ce54c54272fc4ba2
Last active April 1, 2020 10:03
Resizing a Kafka cluster via bash
#!/bin/bash -xe
# requires jq and 3 brokers to start
which jq || echo 'no jq found, bye!' && exit 1
ZK_HOST=zkhost1:2181/kafka
# record all topics
/usr/local/kafka/bin/kafka-topics.sh --zookeeper $ZK_HOST --list > all_topics
# generate json for listing which topics to reassign
@kamermans
kamermans / configure_docker0.sh
Last active April 26, 2024 00:58
Change the IP subnet of Docker's docker0 interface
#!/bin/sh -e
#
# NOTE: Since Docker 1.10 (February 4, 2016), it has been possible to configure the
# Docker daemon using a JSON config file. On Linux, this file is normally located at
# /etc/docker/daemon.json. You should use this JSON config method if you are running
# a version of Docker that is at least 1.10!
# Here is an example configuration that sets the docker0 bridge IP to 192.168.254.1/24:
# {
# "bip": "192.168.254.1/24"
# }
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@bubba-h57
bubba-h57 / ELBAccessToSplunk.php
Last active August 29, 2015 14:00
Script to get AWS Elastic Load Balancer (ELB) Access Logs into Splunk Storm. Keep in mind that ELB ships logs to S3 every five minutes, so if you schedule this to run every five minutes, and it runs as fast as possible, your Splunk will still lag real time by at least five minutes.
#!/usr/bin/php
<?php
/**
* ELBAccessToSplunk.php
*
* Take ELB Access logs that have been shipped to AWS S3
* and transforms them into Splunks generic_single_line
* in a new composite logfile on the system, monitored
* by Splunk Storm.
*
@sn0opy
sn0opy / php.ini
Created April 7, 2014 22:20
hhvm 3.x php.ini
hhvm.server.type = fastcgi
hhvm.server.file_socket = /run/shm/hhvm.sock
hhvm.server.apc.enable_apc = true
hhvm.server.apc.table_type = concurrent
hhvm.server.apc.expire_on_sets = true
hhvm.server.apc.purge_frequency = 4096
hhvm.eval.jit = true
hhvm.eval.jit_warmup_requests = 50
@kamermans
kamermans / mktests.sh
Created March 16, 2014 02:15
Add empty PHPUnit test files for each PHP file in your project
#!/bin/bash
for FILE in $(find ./src/ -type f -name "*.php" | sed -e 's#/src/#/tests/#' -e 's#\.php$#Test.php#'); do
mkdir -p $(dirname $FILE) 2>/dev/null
touch "$FILE"
done
@krakjoe
krakjoe / pool.md
Last active January 30, 2020 12:33
Pooling

Easy pthreads Pools

The final solution !!

Since the first version of pthreads, PHP has had the ability to initialize Worker threads for users. Onto those Worker threads are stacked objects of class Stackable for execution concurrently.

The objects stacked onto workers do not have their reference counts changed, pthreads forces the user to maintain the reference counts in userland, for the extremely good reason that this enables the programmer to keep control of memory usage; and so, execute indefinitely.

This is the cause of much heartache for newcomers to pthreads; if you do not maintain references properly you will, definitely, experience segmentation faults.

@h4cc
h4cc / travis-template-with-hhvm-as-allowed-failure.yml
Last active March 10, 2018 05:01
HHVM Travis-Ci template as allowed failure.
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
matrix:
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@mojodna
mojodna / default.vcl
Created November 12, 2013 20:12
Resolve ELB IPs and create a dynamic Varnish backend list (intended to run out of cron).
# ...
include "dynamic_backends.vcl";
# ...