Skip to content

Instantly share code, notes, and snippets.

View Snaver's full-sized avatar
🏠
Working from home

Richard Snaver

🏠
Working from home
View GitHub Profile
@servers(['web' => $user.'@'.$host,'localhost' => '127.0.0.1'])
@setup
// Sanity checks
if (empty($host)) {
exit('ERROR: $host var empty or not defined');
}
if (empty($user)) {
exit('ERROR: $user var empty or not defined');
}
$TenantID = 'CUSTOMERTENANT.ONMICROSOFT.COM'
$ApplicationId = "YOURPPLICTIONID"
$ApplicationSecret = "YOURAPPLICATIONSECRET"
$body = @{
'resource' = 'https://graph.microsoft.com'
'client_id' = $ApplicationId
'client_secret' = $ApplicationSecret
'grant_type' = "client_credentials"
'scope' = "openid"
@Snaver
Snaver / Detect.ps1
Last active February 20, 2023 15:50
Google Chrome Uninstaller - PowerShell (Local install)
# Based on https://sccmentor.com/2021/01/11/using-proactive-remediations-to-remove-google-chrome/
# Thank you.
try
{
$chromeInstalled = Test-Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe'
if ($chromeInstalled -eq 'True') {
Write-Host "Google Chrome is installed locally"
@Snaver
Snaver / import-news.ps1
Last active February 20, 2023 15:49
SharePoint Online News Import PowerShell Script
function Create-Slug {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$InputString
)
# Use a regular expression to remove any characters that are not letters, numbers, or dashes
$slug = $InputString -replace '[^\w-]', ''
public function humanizeDateDifference($now,$otherDate=null,$offset=null)
{
if($otherDate != null){
$offset = $now - $otherDate;
}
if ($offset == 0)
{
$otherDate =$otherDate + 1;
$offset = $now - $otherDate;
}
# Bitbucket Pipelines Configuration file
# https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
# options:
# size: 2x
# max-time: 60
pipelines:
default:
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
@Snaver
Snaver / file.php
Created March 31, 2017 08:49
WP Rest API - Retrieve sub page by full slug (URL/Path)
<?php
if (strstr($slug, '/')) {
$segments = explode('/', $slug);
$parent_id = null;
foreach ($segments as $key => $segment) {
$params['slug'] = $segment;
if ($parent_id) {
@Snaver
Snaver / App\Geocoder.php
Created May 19, 2020 20:53
geocoder-php / GeocoderLaravel Testing and Mocking Setup
<?php
namespace App;
use Geocoder\Laravel\ProviderAndDumperAggregator as G;
class Geocoder
{
protected $geocoder;
Route::get('/route-list', function () {
Artisan::call('route:list');
return '<pre>'.Artisan::output();
});
# Bitbucket Pipelines Configuration file
# https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
# options:
# size: 2x
# max-time: 60
pipelines:
default:
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."