Skip to content

Instantly share code, notes, and snippets.

@etrepat
etrepat / bundler-exec.sh
Created December 12, 2011 11:03
Automatically run Ruby scripts with "bundle exec". Source: gma/bundler-exec
#!/bin/bash
BUNDLED_COMMANDS="${BUNDLED_COMMANDS:-
cap
capify
cucumber
foreman
guard
haml
heroku
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@etrepat
etrepat / traversing-example.md
Last active April 8, 2021 15:57
Traversing the Hierarchy Tree with Baum - An Example

The simplest way to traverse the hierarchy tree with Baum is by iterating through the children relation.

<?php

$root = Category::roots()->with('children')->first();

echo "<h3>{$root->name}</h3>";

foreach($root->children as $category) {
# db/migrate/XXXXXXXXXXXXX_add_authentication_token_to_users.rb
class AddAuthenticationTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :authentication_token, :string
add_index :users, :authentication_token, :unique => true
end
end
@etrepat
etrepat / baum-standalone.php
Last active November 21, 2016 15:31
Using Baum with stand-alone Eloquent (Capsule) - Laravel 4.2.x
<?php
require __DIR__ . '/vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as DB;
use Baum\Node;
// Initialize Capsule
$capsule = new DB;
// Add connection settings
@etrepat
etrepat / baum-standalone.php
Created March 4, 2015 19:24
Using Baum with stand-alone Eloquent (Capsule) - Laravel 5.0.x
<?php
require __DIR__ . '/vendor/autoload.php';
use Illuminate\Database\Capsule\Manager as DB;
use Baum\Node;
// Initialize Capsule
$capsule = new DB;
// Add connection settings