Skip to content

Instantly share code, notes, and snippets.

View JulienBreux's full-sized avatar

Julien Breux JulienBreux

View GitHub Profile
class Document < ActiveRecord::Base
belongs_to :parent, class_name: 'Document'
def self.get_ancestors(who)
@tree ||= []
# @tree is instance variable of Document class object not document instance object
# so: Document.get_instance_variable('@tree')
if who.parent.nil?
var ioClient = require('socket.io-client')('http://127.0.0.1');
ioClient.on('connect', function () {
ioClient.emit('broadcast', 'first-event', 'Hello');
ioClient.emit('broadcast', 'second-event', 'World');
});
@JulienBreux
JulienBreux / etc-network-interfaces
Last active August 29, 2015 14:16
Proxmox Master Host
auto vmbr1
iface vmbr1 inet static
address 10.10.10.254
netmask 255.255.255.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
@JulienBreux
JulienBreux / Dockerfile
Created February 10, 2015 07:09
Docker + Rails + Redis + Postgres
# base on latest ruby base image
FROM ruby:latest
# update and install dependencies
RUN apt-get update -qq
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential libpq-dev nodejs apt-utils postgresql-client
# setup app folders
RUN mkdir /sample
WORKDIR /sample
@JulienBreux
JulienBreux / PluginAbstract.php
Created August 20, 2014 13:07
Plugin abstract example
<?php
namespace Iadvize\Admin\Plugin;
/**
* Class PluginAbstract
*
* @package Iadvize\Admin\Plugin
*/
abstract class PluginAbstract
@JulienBreux
JulienBreux / README.md
Last active August 29, 2015 14:01
Jira - Epics

How to install?

curl -O https://getcomposer.org/composer.phar
php composer.phar install

How to use?

php -S locahost:8888

@JulienBreux
JulienBreux / gist:10776219
Last active August 29, 2015 13:59
PHP - Error to Exception
<?php
set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontex) {
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
});
@JulienBreux
JulienBreux / index.php
Last active December 26, 2015 08:08
Twilio Test
<?php
// Lib: https://github.com/twilio/twilio-php
require_once __DIR__.'/libs/twilio/Services/Twilio.php';
// Constants
const SID = 'AC...';
const TKN = '...';
const NBR = '+33XXXXXXXXX';
// Variables
@JulienBreux
JulienBreux / crop.php
Created June 19, 2013 12:56
Croping for OpenLayers|OpenStreetMap
#!/usr/bin/php
<?php
$widthTile = 256;
$heightTile = 256;
if (!isset($argv[1]))
{
exit('No input file argument'.PHP_EOL);
}