Skip to content

Instantly share code, notes, and snippets.

@mahdyar
mahdyar / AllowedUsername.php
Last active May 5, 2024 19:18
Prevent your users to register with your route paths like login, or reserved usernames as their usernames in Laravel. More: https://blog.mahdyar.me/2021/04/18/route-paths-and-reserved-usernames-in-laravel/
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\Route;
class AllowedUsername implements Rule
{
/**
@9to5IT
9to5IT / Get-RDM.ps1
Last active May 5, 2024 19:18
PowerShell: Searching for RDM disks using PowerCLI
#requires -version 4
<#
.SYNOPSIS
Seaches for an RDM with the specified LUN ID.
.DESCRIPTION
Searches the vCenter environment to find the Virtual Machine that has an RDM configured with a particular LUN ID.
.PARAMETER None
@9to5IT
9to5IT / Set-HostSNMP.ps1
Created June 7, 2016 13:03
PowerShell: Configure SNMP on an ESXi Host
#requires -version 4
<#
.SYNOPSIS
Configure SNMP Settings on ESXi Hosts
.DESCRIPTION
Connect to vCenter Server and configure all ESXi hosts with SNMP settings
.PARAMETER None
@tykurtz
tykurtz / grokking_to_leetcode.md
Last active May 5, 2024 19:18
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@9to5IT
9to5IT / Find-RegistryValues.ps1
Created June 23, 2016 12:06
PowerShell: Enumerate & Search Registry Key values with PowerShell
$RegKey = (Get-ItemProperty 'HKCU:\Volatile Environment')
$RegKey.PSObject.Properties | ForEach-Object {
If($_.Name -like '*View*'){
Write-Host $_.Name ' = ' $_.Value
}
}
@9to5IT
9to5IT / Manage-ADUsers.ps1
Created July 4, 2016 12:04
PowerShell: Cleanup Inactive AD User Accounts
Import-Module ActiveDirectory
# Set the number of days since last logon
$DaysInactive = 90
$InactiveDate = (Get-Date).Adddays(-($DaysInactive))
#-------------------------------
# FIND INACTIVE USERS
#-------------------------------
# Below are four options to find inactive users. Select the one that is most appropriate for your requirements:
@9to5IT
9to5IT / Manage-ADComputers.ps1
Created July 4, 2016 12:06
PowerShell: Cleanup inactive AD computer objects
Import-Module ActiveDirectory
# Set the number of days since last logon
$DaysInactive = 90
$InactiveDate = (Get-Date).Adddays(-($DaysInactive))
#-------------------------------
# FIND INACTIVE COMPUTERS
#-------------------------------
# Below are three options to find inactive computers. Select the one that is most appropriate for your requirements:
@9to5IT
9to5IT / Manage-ADGroups.ps1
Created July 4, 2016 12:08
PowerShell: Cleanup empty AD Groups
Import-Module ActiveDirectory
#-------------------------------
# FIND EMPTY GROUPS
#-------------------------------
# Get empty AD Groups within a specific OU
$Groups = Get-ADGroup -Filter { Members -notlike "*" } -SearchBase "OU=GROUPS,DC=testlab,DC=com" | Select-Object Name, GroupCategory, DistinguishedName
#-------------------------------
@9to5IT
9to5IT / Manage-ADOUs.ps1
Created July 4, 2016 12:09
PowerShell: Cleanup empty AD OUs
Import-Module ActiveDirectory
#-------------------------------
# FIND EMPTY OUs
#-------------------------------
# Get empty AD Organizational Units
$OUs = Get-ADOrganizationalUnit -Filter * | ForEach-Object { If ( !( Get-ADObject -Filter * -SearchBase $_ -SearchScope OneLevel) ) { $_ } } | Select-Object Name, DistinguishedName
#-------------------------------
@mikejolley
mikejolley / functions.php
Created March 10, 2016 09:39
WooCommerce Disable guest checkout for certain products
<?php
// Code goes in theme functions.php or a custom plugin
add_filter( 'pre_option_woocommerce_enable_guest_checkout', 'conditional_guest_checkout_based_on_product' );
function conditional_guest_checkout_based_on_product( $value ) {
$restrict_ids = array( 1, 2, 3 ); // Replace with product ids which cannot use guest checkout
if ( WC()->cart ) {
$cart = WC()->cart->get_cart();