Skip to content

Instantly share code, notes, and snippets.

Working from home

Chris Fidao fideloper

Working from home
Block or report user

Report or block fideloper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
fideloper / stream_file.php
Last active Aug 29, 2019
Stream file from S3 to browser, assume Laravel Filesystem usage
View stream_file.php
* Get File Information
// Assuming these come from some data source in your app
$s3FileKey = 's3/key/path/to/file.ext';
$fileName = 'file.ext';
fideloper / Gettable.php
Created Mar 9, 2014
Trait for making protected/private attributes "gettable", leaving "setting" the attributes a matter of business logic to be implemented.
View Gettable.php
trait Gettable {
* Retrieve private attributes.
* Attributes should be protected
* so they cannot be *set* arbitrarily.
* This allows us to *get* them as if they
* were public.
fideloper /
Created Jun 4, 2015
Decrypt Laravel-encrypted value
import os
import base64
import json
from Crypto.Cipher import AES
from phpserialize import loads
def decrypt(payload):
data = json.loads(base64.b64decode(payload))
fideloper /
Last active Aug 18, 2019
Update curl on Ubuntu 14.04
#! /usr/bin/env bash
# Install any build dependencies needed for curl
sudo apt-get build-dep curl
# Get latest (as of Feb 25, 2016) libcurl
mkdir ~/curl
cd ~/curl
tar -xvjf curl-7.50.2.tar.bz2
fideloper /
Created Dec 19, 2018
Quick and dirty monitoring of mysql connections
#!/usr/bin/env bash
# 5 minutes between alerts
# Track when we sent the last alert
while true; do
NUMBER_CONNECTIONS=$(mysql --defaults-extra-file=/data/.prod.cnf -sNe "select count(*) as connection_count from INFORMATION_SCHEMA.PROCESSLIST;")
fideloper /
Created Oct 10, 2012
CodeIgniter Style Guide

CodeIgniter Style Guide

This is collectively being called a style guide, however it serves as a standard to enforce a stricter and more enforced methodology in how programming should be done in CodeIgniter.


CodeIgniter is powerful. CodeIgniter is hugely popular. It's popular because it's easy. It's easy because there are many ways to accomplish a task.

CodeIgniter is terrible for the exact reasons which make it powerful. You can too easily place code in a confusing place, or not separate concerns, thus creating programming challenges down the line. It's noob-friendly, which means it's inherently easy to make noob mistakes.

This document serves to restrict coding practices within CodeIgniter with the purpose of making an application with more class (pun without-a-doubt, most-strongly intended).

fideloper /
Created Jun 6, 2012
You should develop in a Virtual Machine

#You should do all your LAMP development in a Virtual Machine

##Here's Why:

Many of us develop on Macintoshes. There are many reasons for this, but one of them is that it's based on a Unix platform of some sort. This allows us to run common server software such as Apache, Ruby, Python and Nodejs on our Macs.

Our computers become powerful develoment machines similar to the servers our apps will eventually live on.

Sometime we start our computer only to find Apache won't start, or MySQL can't create a PID file, or we've updated to Mountain Lion and Apache needs to be reconfigured. Death!

fideloper /
Last active Aug 2, 2019
Enable/Disable xDebug depending on env.
#!/usr/bin/env bash
# A CMD or ENTRYPOINT script for a Dockerfile to use to start a Nginx/PHP-FPM
# For more details, see 🐳
if [ ! "production" == "$APP_ENV" ] && [ ! "prod" == "$APP_ENV" ]; then
# Enable xdebug
fideloper / echo.js
Created Nov 16, 2012
Echo server (node.js)
View echo.js
var net = require("net"), sys = require('sys');
var clients = [], i;
var server = net.createServer(function (stream) {
stream.on("connect", function () {
stream.on("data", function (data) {
console.log(data + "sending to " + clients.length + " clients.");
fideloper / .zshrc
Created Jun 21, 2019
Defer loading of NVM to increase new terminal init speed
View .zshrc
# Thanks to, modified
# for zsh as "type -t" works in bash but not zsh
# Add this to your .zshrc ...
# Defer initialization of nvm until nvm, node or a node-dependent command is
# run. Ensure this block is only run once if .bashrc gets sourced multiple times
# by checking whether __init_nvm is a function.
if [ -s "$HOME/.nvm/" ] && [ ! "$(type -w __init_nvm | awk '{print $2}')" = function ]; then
You can’t perform that action at this time.