Skip to content

Instantly share code, notes, and snippets.

@chustedde
chustedde / Microsoft.PowerShell_profile.ps1
Last active November 17, 2022 14:48
Current profile - just a few useful aliases and functions for what I often do in PowerShell
Function Touch-File
{
$file = $args[0]
if($file -eq $null) {
throw "No filename supplied"
}
if(Test-Path $file)
{
(Get-ChildItem $file).LastWriteTime = Get-Date
}
@chustedde
chustedde / fairyshell.json
Last active April 14, 2017 18:33
Fairyfloss-based theme for PowerShell
{
"black": "#000000",
"dark_blue": "#2A4475",
"dark_green": "#E6C000",
"dark_cyan": "#50c0c0",
"dark_red": "#800000",
"dark_magenta": "#800080",
"dark_yellow": "#808000",
"gray": "#F8F8F2",
"dark_gray": "#aaaaaa",
@chustedde
chustedde / export-gitlab-snippets.ps1
Created July 14, 2016 21:38
Export snippets from GitLab
# Quick 'n' dirty script to export snippets from GitLab to local files. Useful if you're
# migrating to GitHub or just want to back up your snippets as files. Doesn't catch errors
# or anything like that, but what were you expecting for a Gist? :-) Also, this will only
# export snippets that are visible to you, so other users' private snippets are excluded.
# Tested with GitLab v8.5.1
$username = "username" # Your username goes here
$password = "password" # Your password goes here
$baseURL = "https://your.gitlab.base.url" # Your GitLab base URL goes here
@chustedde
chustedde / add-authorig.ps1
Created March 17, 2016 15:33
The AD Users and Computers interface won't let you edit the authOrig property of a Distribution Group until you set an initial value. You need to use a real DN because it will check the validity before adding it. After doing this, you can add/edit the authorized senders from the AD Users and Computers GUI.
Set-ADGroup -Identity "Test Group" -Server contoso.edu -Add @{authOrig=@('CN=Joe Test,OU=Department,OU=People,DC=CONTOSO,DC=EDU’)}
@chustedde
chustedde / picki.js
Last active December 20, 2015 09:40
A mixin for underscore.js: Case-insensitive pick that returns an object with keys in the original case. Demo at http://jsfiddle.net/chustedde/Thv2w/
_.mixin({
// Case-insensitive pick that returns an object with keys in the original case
picki : function(obj, keys) {
var copy = {};
var objKeyList = _.keys(obj);
_.each(keys, function(key) {
_.each(objKeyList, function(o){
if (key.toString().toLowerCase() === o.toString().toLowerCase()) {
// o is from the list of keys extracted from the object, so