Skip to content

Instantly share code, notes, and snippets.

@dcabanaw
dcabanaw / docker-compose.yml
Last active August 17, 2025 10:34
docker compose for GUI APP with nvidia gpu acceleration (for Lychee Slicer)
version: '3.8' # Specifies the version of the Docker Compose file format
services:
ros: # Service name
image: osrf/ros:humble-desktop # Specifies the Docker image to use for this service
container_name: ros # Sets the container name to "ros"
network_mode: host # Uses the host's networking stack (container shares the host's network)
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix # Mounts the X11 Unix socket for GUI applications
- /etc/localtime:/etc/localtime:ro # Mounts the local timezone file in read-only mode to sync container time
@dcabanaw
dcabanaw / Store.php
Created April 14, 2016 20:02
a simple (:effort:) key value store
<?php
class Store
{
public function __construct(\PDO $db)
{
$this->db = $db;
$this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
}
@dcabanaw
dcabanaw / ApplicationPolicy.php
Last active June 30, 2022 13:41
ACL in Laravel: Roles and Permissions fix for booting when scheming is not created...
<?php
namespace App\Policies;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
class ApplicationPolicy
{
/**
* @var GateContract
*/
@dcabanaw
dcabanaw / Bin.php
Created September 3, 2015 20:39
Simple bin packing
<?php
class Bin
{
private $capacity;
private $content;
/**
* @param integer $capacity
* @param array $content
@dcabanaw
dcabanaw / BinPool.php
Last active September 3, 2015 20:44
naive attempt at a 0-1 knapsack type solution... Am I the coding horror?
<?php
/**
* Class BinPool
* simple implementation of the 0-1 Knapsack problem, with multiple knapsacks (bins)
*
* Given a pool of item sizes/weights, a bin size and a quantity of bins, can the pool be fully allocated to the bins
* and have room to add another item
*/
<?php
// example_1
// creates a new Request from the default namespace ie "\Request"
$x = new Request();
// example_2
// creates a new Request from the CorpName\App namespace ie "CorpName\App\Request"
namespace CorpName\App;
$x = new Request();