Skip to content

Instantly share code, notes, and snippets.

View dhrrgn's full-sized avatar
🦙

Dan Horrigan dhrrgn

🦙
  • OH, USA
  • 14:24 (UTC -04:00)
View GitHub Profile
@dhrrgn
dhrrgn / csrf.php
Created October 23, 2011 06:25
Simple, yet effective CSRF class for FuelPHP.
<?php
/**
* Simple, yet effective CSRF class for FuelPHP.
*
* @author Dan Horrigan
* @license MIT License
* @copyright 2011 Dan Horrigan
*/
/**
@dhrrgn
dhrrgn / iter.php
Created August 1, 2013 15:57
(WIP) Functions creating iterators for looping, based off the python itertools module.
<?php
/**
* Functions creating iterators for looping, based off the python itertools
* module.
*
* @author Dan Horrigan <dan@dhorrigan.com>
* @license MIT License
* @copyright 2013 Daniel Horrigan
*/
namespace iter;
@dhrrgn
dhrrgn / console
Last active December 12, 2021 01:24
Adding global Options/Arguments to Symfony Console Applications
#!/usr/bin/env php
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
require 'vendor/autoload.php';
$app = new Application;
package com.yourapp.navbar;
import android.app.Activity;
import android.view.View;
import com.facebook.react.ReactActivity;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@dhrrgn
dhrrgn / cmd.py
Last active May 17, 2021 18:41
Running a command in Python and optionally processing the output in realtime.
import shlex
import subprocess
import sys
def run_cmd(cmd, callback=None, watch=False):
"""Runs the given command and gathers the output.
If a callback is provided, then the output is sent to it, otherwise it
is just returned.
@dhrrgn
dhrrgn / gist:10125477
Last active February 26, 2021 18:42
Upgrade Ubuntu OpenSSL to patch Heartbleed
sudo apt-get update
sudo apt-get install -y libssl1.0.0 openssl
# Confirm Build Date is at least Aril 7th 2014
openssl version -a
# Restart all services listed by this command:
sudo lsof -n | grep ssl | grep DEL
@dhrrgn
dhrrgn / profiling.md
Last active February 4, 2021 21:28
Profiling your PHP Application

XDebug Profiling

XDebug Config

xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "/path/to/folder/for/cachegrind/files"
xdebug.profiler_output_name = "callgrind.out.%t.%p"

Install QCacheGrind (for OSX Mavericks)

@dhrrgn
dhrrgn / ansiconv.py
Created August 22, 2013 19:33
Converts ANSI coded text and converts it to either plain text or to HTML.
"""
ansiconv
Converts ANSI coded text and converts it to either plain text
or to HTML.
:author Dan Horrigan <dan@dhorrigan.com>
:copyright 2013 Dan Horrigan
:license MIT
"""
@dhrrgn
dhrrgn / DataContainer.php
Last active December 21, 2020 02:30
Data Container Class and Trait
<?php
use ArrayAccess;
use Countable;
use IteratorAggregate;
class DataContainer implements ArrayAccess, Countable, IteratorAggregate
{
use DataContainerTrait;
}
@dhrrgn
dhrrgn / status.conf
Created January 27, 2014 15:10
Nginx status endpoint.
server {
listen 80;
server_name localhost;
location /status {
access_log off;
default_type text/plain;
return 200 "alive";
}
}