Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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)
<?php
require __DIR__.'/vendor/autoload.php';
set_time_limit(600);
$app = require_once __DIR__.'/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
use Statamic\Facades\Stache;
use Statamic\Facades\Entry;