Skip to content

Instantly share code, notes, and snippets.

View snobu's full-sized avatar

Adrian Calinescu snobu

View GitHub Profile
ConfigurationMode
ConfigurationMode defines how the DSC client operates. Â There are three valid values:
Apply
ApplyAndMonitor
ApplyAndAutoCorrect
(NOTE: Â These descriptions of functionality are based on limited testing – the TechNet documentation is not up to date yet, but should be in the near future.)
Apply will apply the configuration once and after a successful run is logged, it will stop attempting to apply configuration or checking the configuration. Â ApplyAndMonitor will apply a configuration as in Apply, but will continue to validate that a node is configured as described. Â No corrective action will take place if there is configuration drift. Â Finally, ApplyAndAutoCorrect is what most of us think of when looking at DSC as a configuration management tool. Â This setting applies a configuration and checks it regularly. Â If configuration drift is detected, the configuration manager will attempt to return the machine to the desired state (see how I worked the product name in there..).
SetScript = {
$rules = 'File and Printer Sharing (Echo Request - ICMPv6-In)',
'File and Printer Sharing (Echo Request - ICMPv4-In)'
$rules.ForEach({
$netsh = "netsh.exe --% advfirewall firewall set rule name=`"$_`" new enable=YES"
invoke-expression -Command ($netsh)
})
}
PS> Get-Net6to4Configuration
Description : 6to4 Configuration
State : Disabled
AutoSharing : Default
RelayName : 6to4.ipv6.microsoft.com.
RelayState : Default
ResolutionIntervalSeconds : 1440
/**
* Converts an HSL color value to RGB. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes h, s, and l are contained in the set [0, 1] and
* returns r, g, and b in the set [0, 255].
*
* @param Number h The hue
* @param Number s The saturation
* @param Number l The lightness
* @return Array The RGB representation
@snobu
snobu / enumcerts.sh
Created May 12, 2016 07:47
Count certs in TLS handshake
while true
do
if [ $(openssl s_client -showcerts -connect $1:443 -servername $1 2>&1 < /dev/null | grep "BEGIN CERTIFICATE" | wc -l) != 2 ]
then echo "!!!INTERMEDIATE NOT SERVED!!! OpenSSL exit code = $?"
fi
sleep 1
done
@snobu
snobu / IsSubDirectory.cs
Last active November 2, 2016 14:42
IsSubDirectory.cs
// https://github.com/projectkudu/KuduSync.NET/blob/5ff87c07d69ed7ce250267d4657c262c89dd547b/KuduSync.NET/FileSystemHelpers.cs#L80
using System;
using System.IO;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
@snobu
snobu / clearInterval.js
Created November 7, 2016 23:08
clearInterval
a = true;
var timer = setInterval(function() {
console.log('loop..');
if (a == false) {
console.log('break');
clearInterval(timer);
}
}, 3000);
@snobu
snobu / Transform.cs
Created December 20, 2016 19:47
ImageProcessor sample transform
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using ImageProcessor;
using ImageProcessor.Imaging.Formats;
@snobu
snobu / repeat.cs
Last active December 29, 2016 07:47
C# Repeat a String
using System.Linq;
//
string.Concat(Enumerable.Repeat("fa la la la la", 2));
@snobu
snobu / function.json
Last active January 27, 2017 15:04
Powershell-to-FunctionApp-to-TableStorage
{
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in"
},
{
"name": "$return",