Skip to content

Instantly share code, notes, and snippets.

@cveld
cveld / main.tf
Created February 16, 2024 11:19
Cycle through two certs every 5 secs
# Ultimately we obviously increase the numbers to e.g. 6 months
locals {
plantimestamp = plantimestamp()
secs = format("%02d", floor(tonumber(formatdate("ss", local.plantimestamp)) / 10) * 10)
rounded = "${formatdate("YYYY-MM-DD", local.plantimestamp)}T${formatdate("hh:mm", local.plantimestamp)}:${local.secs}Z"
diff = timecmp(local.value2, local.plantimestamp)
s1 = local.rounded
value2 = timeadd(local.rounded, "5s")
s2 = local.diff == 1 ? timeadd(local.rounded, "-5s") : local.value2
@cveld
cveld / Crawl_Android.ps1
Last active February 22, 2023 06:35
PowerShell that crawls your Android usb folder structure
# http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/26/use-powershell-to-work-with-windows-explorer.aspx
$o = New-Object -com Shell.Application
$folder = $o.NameSpace(0x11)
# https://msdn.microsoft.com/en-us/library/windows/desktop/bb774096(v=vs.85).aspx
# ShellSpecialFolderConstants.ssfDRIVES == 0x11
$items = $folder.Items()
for ($i= 0; $i -lt $items.Count; $i++) {
write-output ([string]$i + ": " + $items.Item($i).Name)
@cveld
cveld / Export-VwanTopology.ps1
Created November 7, 2022 15:27
Export Vwan Topology - all cidrs of underlying vnet connections
# You can run this script like so:
# . .\vwan-topology-export.ps1 -VirtualWanName vwan-platform-prd-weu-001 | select -Property Component, Name, Cidr, Parent, ParentType | ConvertTo-Csv | Set-Content output.csv
param(
[Parameter(Mandatory=$true)]
$VirtualWanName
)
$vwan = Get-AzVirtualWan -Name $VirtualWanName
$vwanresource = Get-AzResource -ResourceId $vwan.id
@cveld
cveld / customerprofile.cmd
Created August 9, 2021 11:12
Start separate Teams desktop session
@ECHO OFF
REM Uses the file name as the profile name
SET MSTEAMS_PROFILE=%~n0
ECHO - Using profile "%MSTEAMS_PROFILE%"
SET "OLD_USERPROFILE=%USERPROFILE%"
SET "USERPROFILE=%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%"
ECHO - Launching MS Teams with profile %MSTEAMS_PROFILE%
cd "%OLD_USERPROFILE%\AppData\Local\Microsoft\Teams"
"%OLD_USERPROFILE%\AppData\Local\Microsoft\Teams\Update.exe" --processStart "Teams.exe"
*** Settings ***
Documentation A test suite with a single test for valid login.
...
... This test has a workflow that is created using keywords in
... the imported resource file.
Resource resource.txt
*** Test Cases ***
Valid Login
Open Browser To Login Page
@cveld
cveld / test.cs
Created August 9, 2018 19:39
A test for a new blog
using test;
class Happy {
void MyFunction(int i) {
test.Method(i);
}
}
@cveld
cveld / ce_followedsites.html
Last active July 25, 2016 15:56
Client-side Content Editor / Script Editor include in order to extend the SharePoint 2013 content by search and search results webparts with a new token for filtering on followed sites by the active user
<script type="text/javascript">
(function(){
// Content Editor / Script Editor include in order to extend the SharePoint 2013 content by search and search results webparts with a new token for filtering on followed sites by the active user
// (c) 2015 Carl in 't Veld
// dependencies: jQuery
// This script works by introducing two extensions on top existing SharePoint OOTB functions:
// 1. SP.ClientRuntimeContext
// Extending the function executeQueryAsync, we create a stack in the ClientRuntimeContext instance
@cveld
cveld / readiislog.scala
Created January 3, 2016 21:31 — forked from anonymous/readiislog.scala
First try to parse IIS (w3c extended format log files with Scala
// http://stackoverflow.com/questions/1284423/read-entire-file-in-scala
//val source = scala.io.Source.fromFile("G:\\test\\2015-12 Logging Eventhub\\W3SVC916189047\\u_ex151130.log")
val source = scala.io.Source.fromFile("testlog.log")
val lines = source.getLines()
//getLogItems(lines).take(5).foreach { line => println(line) }
getLogItems(lines).foreach { line => println(line) }
class LogItemsIterator(lines : Iterator[String]) extends Iterator[collection.mutable.Map[String, String]] {
var _nextLine = None : Option[collection.mutable.Map[String, String]];