Skip to content

Instantly share code, notes, and snippets.

@hastinbe
hastinbe / rc.inet1
Created December 6, 2024 22:22
Dynamic File Descriptor Limit for dhcpcd on Unraid OS 6.12.12. Modified script to dynamically calculate and set the nofile limit for dhcpcd based on the number of network interfaces. Ensures child processes inherit appropriate limits to prevent warnings in tools like Netdata.
#!/bin/sh
# /etc/rc.d/rc.inet1
# This script is used to bring up the various network interfaces.
#
# @(#)/etc/rc.d/rc.inet1 10.2 Sun Jul 24 12:45:56 PDT 2005 (pjv)
# Adapted by Bergware for use in unRAID - April 2016
# - improved interface configuration
# - added VLAN (sub-interface) support
# - removed wireless (unsupported)
@hastinbe
hastinbe / qbittorrent_hash.py
Created January 9, 2024 15:20
Generates a PBKDF2 hash for qBittorrent WebUI password. This is useful for setting the password in the config file.
#!/usr/bin/env python
#
# Generates a PBKDF2 hash for qBittorrent WebUI password. This is useful for setting the password in the config file.
#
# NOTE: Hashing algorithm must match https://github.com/qbittorrent/qBittorrent/blob/master/src/base/utils/password.cpp
#
# Usage: python qbittorrent_hash.py
#
# Author: Beau Hastings (https://github.com/hastinbe)
# Date: 2024-01-09
@hastinbe
hastinbe / 0_main.dart
Created January 1, 2021 13:07 — forked from boformer/0_main.dart
Flutter Service Architecture
import 'package:architecture_playground/home_page.dart';
import 'package:architecture_playground/services.dart';
import 'package:flutter/material.dart';
void main() async {
// perform long-running tasks before "runApp" to display the native splash screen
final services = await Services.initialize();
runApp(ServicesProvider(
services: services,
@hastinbe
hastinbe / singleton-pattern.php
Last active September 13, 2019 01:52
Singleton Pattern Example #php #design-patterns #singleton-pattern
<?php
class Singleton
{
private static $instance;
public static function getInstance()
{
if (static::$instance === null) {
static::$instance = new static();
@hastinbe
hastinbe / facade-pattern.php
Created September 13, 2019 01:50
Facade Pattern Example #php #design-patterns #facade-pattern
<?php
const BOOT_ADDRESS = 0xd34db33f;
const BOOT_SECTOR = 0x7c;
const SECTOR_SIZE = 4096;
interface IComputer
{
public function powerOn();
public function powerOff();
@hastinbe
hastinbe / decorator-pattern.php
Created September 13, 2019 01:49
Decorator Pattern Example #php #design-patterns #decorator-pattern
<?php
interface IGreeting
{
public function greeting();
}
abstract class GreetingDecorator implements IGreeting
{
protected $greeter;
@hastinbe
hastinbe / composite-pattern.php
Created September 13, 2019 01:48
Composite Pattern Example #php #design-patterns #composite-pattern
<?php
abstract class Component
{
protected $_parent;
protected $_children;
public function __construct()
{
$this->_children = new SplDoublyLinkedList();
}
@hastinbe
hastinbe / bridge-pattern.php
Created September 13, 2019 01:47
Bridge Pattern Example #php #design-patterns #bridge-pattern
<?php
abstract class Window
{
protected $impl;
public function __construct(WindowImpl $impl)
{
$this->setWindowImpl($impl);
}
@hastinbe
hastinbe / container.php
Last active September 13, 2019 01:43
An example of a rudimentary dependency injection container #php #dic
<?php
interface Database {}
class Mysql implements Database {}
class Postgresql implements Database {}
class Container
{
protected $bindings = [];
@hastinbe
hastinbe / gps.php
Last active September 13, 2019 01:37
Gets EXIF GPS data from an image #php #gps
<?php
/**
* GPS helper class.
*
* @package Gps
*
* @author Beau Hastings <[email protected]>
* @copyright 2019 Beau Hastings
* @license GNU GPL v2
*