Skip to content

Instantly share code, notes, and snippets.

@vors
vors / SlackAutoInvite.js
Last active May 9, 2020 17:51
Automation for sending Invites on Slack. Based on Google Forms and Google script. For more context read https://levels.io/slack-typeform-auto-invite-sign-ups/
/*
To automate your slack instance invites,
1. Create a google form with two text fields:
"Your email"
"Who invite you"
2. You will get a google table with responses and 3 fields:
1) "Timestamp"
@vors
vors / MamlToMarkdown.psm1
Created September 12, 2015 01:51
Maml to Markdown proof-of-concept converter (intended to be a standalone repo eventually)
function Convert-MamlLinksToMarkDownLinks
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$false, ValueFromPipeline=$true)]
$maml
)
process
{

Keybase proof

I hereby claim:

  • I am vors on github.
  • I am vors (https://keybase.io/vors) on keybase.
  • I have a public key whose fingerprint is 5397 6AD9 7CCE 3AB7 751D 0A8B 2532 CAE8 5D8D 6940

To claim this, I am signing this object:

@vors
vors / azure-dsc-extension-schema.json
Created April 10, 2015 18:49
Experimental json schema of DSC azure extension
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://schema.management.azure.com/schemas/2014-04-01/Microsoft.Powershell.DSC.json",
"title": "Microsoft.Powershell.DSC",
"description": "Microsoft.Powershell.DSC Extension for Azure VMs",
"definitions": {
"DscConfigurationArguments": {
"oneOf": [
{
"type": "array",
@vors
vors / xmlToString.ps1
Created March 21, 2015 21:13
PowerShell function to convert any [xml] element to string
function Convert-XmlElementToString
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
$xml
)
$sw = [System.IO.StringWriter]::new()
$xmlSettings = [System.Xml.XmlWriterSettings]::new()
@vors
vors / hacky_const.ps1
Created March 11, 2015 16:40
Workaround that can be used in WMF 5 February Preview to emulate const.
# don't use it, it's a workaround
class ClassWithConst
{
[ValidateSet(100)]
static [int] $CONST_FOO = 100
}
[ClassWithConst]::CONST_FOO
[ClassWithConst]::CONST_FOO = 10
@vors
vors / PS-blog-post-formatting.html
Created February 28, 2015 01:18
Formatting that can be used to style blog post about PowerShell
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Replace this gist by your own blog gist -->
<script src="https://gist.github.com/vors/4bf101a457e6816f3c0f.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$('.markdown-body > p > code')
.css("white-space","nowrap");
@vors
vors / ScriptAnalyzer.ps1
Created February 25, 2015 00:02
Script Analyzer sample 1
<#
.SYNOPSIS
You should never use Write-Host to create any script output whatsoever.
.DESCRIPTION
It is generally accepted that you should never use Write-Host to create any script output whatsoever, unless your script (or function, or whatever) uses the Show verb (as in, Show-Performance).
That verb explicitly means “show on the screen, with no other possibilities.” Like Show-Command.
To fix a violation of this rule, please replace Write-Host with Write-Output in most scenarios.
.EXAMPLE
Test-WriteHost -CommandAst $CommandAst
.INPUTS
@vors
vors / revert.js
Created January 19, 2015 20:32
Revert colors for open and closed issues in github
// past this line to dev tools console
a = $(".closed.octicon"); for (var i = 0; i < a.length; i++) { a[i].style.color = 'green'}; a = $(".open.octicon"); for (var i = 0; i < a.length; i++) { a[i].style.color = 'red'}
@vors
vors / profile.ps1
Created December 16, 2014 03:12
Sample of $profile.CurrentUserAllHosts file that can be used to load profile only when session is interactive
# This is $profile.CurrentUserAllHosts file
function Get-IsSessionIntaractive() {
$parentProcess = Get-Process -id (Get-WmiObject Win32_Process -Filter "ProcessId = '$pid'").ParentProcessId
$parentProcess.Name -eq "explorer"
}
# put your profile in this file and access it with $psrc instead of $profile
$psrc = 'C:\Users\sevoroby\Documents\WindowsPowerShell\psrc.ps1'
if (Get-IsSessionIntaractive)