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 / Vagrantfile
Created September 22, 2014 17:20
Force installation of Vagrant plugins.
unless Vagrant.has_plugin?("<PluginName>")
system('vagrant plugin install <PluginName>')
raise("Plugin installed. Run command again.");
end
@zachflower
zachflower / MY_Input.php
Last active August 29, 2015 14:08
CodeIgniter input class, implementing PATCH and DELETE HTTP request methods
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Input extends CI_Input {
protected $raw;
protected $delete;
protected $patch;
public function __construct() {
parent::__construct();
@zachflower
zachflower / rainbow.cpp
Last active February 19, 2024 09:34
Smooth RGB LED Color Transitions (Arduino)
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
int r = 0;
int g = 0;
int b = 0;
void setup() {
pinMode(redPin, OUTPUT);
@zachflower
zachflower / hello-world.json
Created November 26, 2015 02:30
Example API Blueprint JSON
{
"element": "category",
"meta": {
"classes": [
"api"
],
"title": "Hello World API"
},
"content": [
{
@zachflower
zachflower / hello-world.md
Created November 26, 2015 02:34
Example API Blueprint Markdown

Hello World API

A Hello World API. Always returns “Hello World”.

Hello World [/hello]

Return “Hello World.” Always.

GET resource [GET]

Make a GET request.

  • Response 200 (text/plain)
<?php
private function isFromTrustedProxy() {
return self::$trustedProxies&&IpUtils::checkIp($this->server->get(‘REMOTE_ADDR’), self::$trustedProxies);
}
?>
<?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;