Skip to content

Instantly share code, notes, and snippets.

@Marko298
Marko298 / make_dhcp.sh
Last active October 12, 2025 11:50
Make Proxmox instance receive ip from DHCP
#!/bin/bash
# ==============================================================================
# Proxmox VE - Single Node DHCP Configuration Script (Updated)
#
# This script automates switching a single Proxmox VE node from a static IP
# to DHCP. It is configured to:
# 1. Prefer IPv4 addresses over IPv6.
# 2. DE-PRIORITIZE IPv4 addresses in the 100.0.0.0/8 network range.
#
const { Readable } = require('stream');
const { pipeline } = require('stream/promises');
const pipe = require('pipeline-pipe');
async function process(a) {
await sleep(100);
return a;
}
@Marko298
Marko298 / Enum.php
Last active October 6, 2020 07:58
Enum caster
<?php
namespace App\Enums;
use App\Casts\EnumCast;
use Illuminate\Contracts\Database\Eloquent\Castable;
abstract class Enum extends \Spatie\Enum\Enum implements Castable
{
public static function castUsing()
@Marko298
Marko298 / UserResource.php
Created August 6, 2020 09:46
UserResource with fresh token
<?php
namespace App\Http\Resources;
use App\Models\User;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin \App\Models\User */
class UserResource extends JsonResource
{
@Marko298
Marko298 / composer.json
Last active August 27, 2020 18:54
Composer hooks for nova and ide-helper
{
//...composer.json content
"scripts": {
//...existsing scripts
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"@php artisan nova:publish",
"@php artisan ide-helper:generate",
@Marko298
Marko298 / SocialLoginController.php
Last active December 4, 2022 23:36
Social Login Controller
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Resources\UserResource;
use App\Models\SocialAccount;
use App\Models\User;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Http\Request;
<?php
function calcControlBit(array $input, array $controllingBits): int
{
$ones = 0;
foreach ($controllingBits as $bit) {
if ($input[$bit] === 1) {
$ones++;
}
}