Skip to content

Instantly share code, notes, and snippets.

View fideloper's full-sized avatar
🏠
Working from home

Chris Fidao fideloper

🏠
Working from home
View GitHub Profile
@fideloper
fideloper / apache2.conf
Last active December 29, 2015 13:49
Ubuntu Apache Default logrotate config
/var/log/apache2/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
@fideloper
fideloper / splunkstorm.sh
Created November 1, 2012 02:56
Ubuntu - Install Splunkstorm.com forwarder
# Splunk Storm
$ wget [ Download Splunk url ]
$ gunzip -c splunkforwarder-5.0-140868-Linux-x86_64.tgz | tar -xvpf -
$ ./splunkforwarder/bin/splunk start
$ ./splunkforwarder/bin/splunk install app stormforwarder_3de50bc823a711e2b4a81231390e9c34.spl -auth admin:changeme
$ ./splunkforwarder/bin/splunk login -auth admin:changeme
$ ./splunkforwarder/bin/splunk edit user admin -password whatever_you_want
$ ./splunkforwarder/bin/splunk add forward-server forwarder.splunkstorm.com:9997
$ ./splunkforwarder/bin/splunk add monitor /var/www/monologapp/log/fideloper.log # Starts sending data
$ ./splunkforwarder/bin/splunk add monitor /var/log/apache2/error.log
@fideloper
fideloper / echo.js
Created November 16, 2012 14:48
Echo server (node.js)
var net = require("net"), sys = require('sys');
var clients = [], i;
var server = net.createServer(function (stream) {
stream.setEncoding("utf8");
stream.on("connect", function () {
clients.push(stream);
});
stream.on("data", function (data) {
console.log(data + "sending to " + clients.length + " clients.");
@fideloper
fideloper / io.js
Created November 26, 2012 20:02
socket.io
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
app.listen(80);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
@fideloper
fideloper / index.html
Created November 26, 2012 21:01
client/server socket.io
<!DOCTYPE html>
<html>
<head><title>Socket Test</title></head>
<body>
<button id="btn">Click Me</button>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://192.168.1.199:8888');
@fideloper
fideloper / client.js
Created November 27, 2012 01:31
Engine.io and server Client.io
// Install with 'npm install engine.io-client'
// Run in node.js as a client! (Not browser-only!)
/* Socket client */
var eio = require('engine.io-client');
var socket = new eio.Socket({ host: 'localhost', port: 8080 });
socket.onopen = function () {
@fideloper
fideloper / User.php
Last active October 4, 2018 05:54 — forked from anonymous/testable_user.php
An example of making a User class testable and maintainable, using dependency injection and some abstraction.
<?php
// Often, we see a class like this:
class User {
public function getCurrentUser()
{
$user_id = $_SESSION['user_id'];
$user = App::db->select('user')
@fideloper
fideloper / SampleApp.md
Last active December 10, 2015 09:49
A sample application using Containers, for use with explanation of Dependency Injection, Maintainability and Containers - https://gist.github.com/4394248.

Example Application

Here's a portion of a theoretical application.

First, let's set some configurations. Our Application class will extend the container class of choice, Pimple.

We'll use our container to hold our database connection as well as our user object.

Note that we're using the container in order to instantiate our User class with the MySql implementation of a data store. This lets us change the storage in one location (this config file).

@fideloper
fideloper / install_laravel4.sh
Last active December 10, 2015 13:18
One-line installer for Laravel 4 (WIP)
#! /bin/bash
wget -O - https://github.com/illuminate/app/tarball/master > laravel4.tar.gz
tar -zxf ./laravel4.tar.gz
rm ./laravel4.tar.gz
mv illuminate-app-* laravel4 # decompresses to illuminate-app-[sha1 hash] :/
if [ -d laravel4 ]; then
cd laravel4
mkdir bin
@fideloper
fideloper / app.js
Last active October 17, 2016 04:05
Using Event Emitter in your node modules
var Fancy = require('FancyModule');
var mod = new Fancy();
mod.on('success', function(data) {
console.log(data); // { this_is_fancy:'indubitably' }
});