Skip to content

Instantly share code, notes, and snippets.

View zachflower's full-sized avatar
💾

Zachary Flower zachflower

💾
View GitHub Profile
@zachflower
zachflower / Queue.class.php
Last active August 24, 2016 13:24
PHP implementation of a queue.
<?php
// http://www.cplusplus.com/reference/queue/queue/
class Queue {
private $_queue = array();
public function size() {
return count($this->_queue);
}
@zachflower
zachflower / Stack.class.php
Last active August 24, 2016 13:24
PHP implementation of a stack.
<?php
// http://www.cplusplus.com/reference/stack/stack/
class Stack {
private $_stack = array();
public function size() {
return count($this->_stack);
}
@zachflower
zachflower / BinarySearchTree.class.php
Created June 13, 2014 16:47
PHP implementation of a binary search tree.
<?php
class Node {
public $level = 1;
public $data = NULL;
public $left = NULL;
public $right = NULL;
public function __construct($data = NULL) {
$this->data = $data;
@zachflower
zachflower / Dockerfile
Last active August 24, 2016 06:49
Codeship Dockerfile
# Start with the offical image for PHP 5.6
FROM php:5.6
# Install additonal packages
RUN apt-get update
RUN apt-get install -y git unzip libmcrypt-dev libmemcached-dev libz-dev
RUN pecl install memcached
# Install/Enable PHP extensions
RUN docker-php-ext-install pcntl mcrypt
@zachflower
zachflower / codeship-services.yml
Last active August 24, 2016 06:49
Codeship Services
app:
build:
image: app
dockerfile_path: Dockerfile
cached: true
@zachflower
zachflower / codeship-steps.yml
Last active August 24, 2016 06:49
Codeship Steps
- type: parallel
steps:
- service: app
command: vendor/bin/phpunit
@zachflower
zachflower / codeship-systems.yml
Last active August 24, 2016 06:47
Codeship Multiple Services
build:
build:
image: app
dockerfile_path: Dockerfile
cached: true
volumes_from:
- data
test:
build:
image: app
<?php
if($forwardedFor=$request->headers->get(‘X_FORWARDED_FOR’)){
$forwardedIps=explode(“, “,$forwarded_for);
foreach($forwardedIpsas$forwardedIp){
if(\Symfony\Component\HttpFoundation\IpUtils::checkIp($forwardedIp,$proxyIps)){
$proxyIps[]=$request->server->get(‘REMOTE_ADDR’);
break;
<?php
private function isFromTrustedProxy() {
return self::$trustedProxies&&IpUtils::checkIp($this->server->get(‘REMOTE_ADDR’), self::$trustedProxies);
}
?>
@zachflower
zachflower / tor.php
Last active December 28, 2015 20:29
Tor Page Crawler
<?php
/**
* Tor Page Crawler
*
* Download web pages anonymously using the Tor network.
* Usage Example:
* $tor = new Tor();
*
* $tor->setUrl('http://zacharyflower.com');