Skip to content

Instantly share code, notes, and snippets.

View kamermans's full-sized avatar
😏

Steve Kamerman kamermans

😏
View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active April 9, 2024 21:04
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@nzjrs
nzjrs / skype-notify.py
Created June 3, 2011 13:14
Python script to make Skype co-operate with GNOME3 notifications
#!/usr/bin/env python
# Python script to make Skype co-operate with GNOME3 notifications.
#
#
# Copyright (c) 2011, John Stowers
#
# Adapted from skype-notify.py
# Copyright (c) 2009, Lightbreeze
#
#
@linickx
linickx / cidr2mask.php
Created October 24, 2011 16:04
php network functions
<?php
function cidr2mask($netmask) {
$netmask_result="";
for($i=1; $i <= $netmask; $i++) {
$netmask_result .= "1";
}
for($i=$netmask+1; $i <= 32; $i++) {
@aderowbotham
aderowbotham / purge-ban-domain-varnish.md
Last active May 24, 2022 19:55
Purge (ban) an entire domain in Varnish Cache 3

How to purge ('ban') an entire domain in Varnish Cache 3

#####EDIT: NB Ban is technically different from Purge. Banned objects remain in memory but banning is faster than purging. Read the Varnish 3 documentation here and here.

Purge may be a more appropriate action for your use-case; although the examples in the gist below work, it's not necessarily the best way of doing this.


@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";
# ...
@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
@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:
@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.

@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
@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