This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Selected hand-copied text from https://www.youtube.com/watch?v=FjhRkfAuU7I#t=2035 | |
// Article at https://databricks.gitbooks.io/databricks-spark-reference-applications/content/twitter_classifier/index.html | |
// references this video, but the provided code is different than video. | |
// The video does a bunch of stuff to obtain and process the tweets, but | |
// what "val texts = " becomes is simply an array of strings, so I just | |
// made a text file with one log entry per line (I'm trying to classify logs) | |
// and did something like: | |
val texts = sc.textFile("input.log") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<!-- NOTE: This code started with a copy of index.html from https://bl.ocks.org/mbostock/4063570 which is: --> | |
<!-- LICENSE: GPL version 3 https://opensource.org/licenses/GPL-3.0 --> | |
<head> | |
<style> | |
<meta charset="utf-8"> | |
.node circle { | |
fill: #fff; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"`nWalking the XML tree`n" | |
$WeirdThingy = [xml](Get-Content "test.audit") | |
$RemoveNodes = @() | |
# Walk the nodes, match text and add nodes to $RemoveNodes array | |
$WeirdThingy.check_type.ChildNodes | ForEach-Object { | |
if ($_.InnerText -match '8.1.1.1') { | |
$RemoveNodes += $_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In reply to https://www.reddit.com/r/PowerShell/comments/4a08hk/importcsv_with_as_a_hashtable/ | |
# Public Google Form at https://docs.google.com/a/jimnelson.us/forms/d/1dYmWTcw3c3q9p3HGWGvbNDvXWekUEKQfgsecZOpsV-k | |
# Results are at https://docs.google.com/spreadsheets/d/1G7J8qCL4gQ_NSYLiGE_3dauSaa75ppzPmcO-Rl7yV6w | |
[cmdletbinding()] | |
param( | |
$SheetKey = "1G7J8qCL4gQ_NSYLiGE_3dauSaa75ppzPmcO-Rl7yV6w", | |
$MaxRows = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the weather | |
$wttr = Invoke-WebRequest http://wttr.in/ | |
# Regex to match lines with no data in them, including blank lines and decorative borders | |
$RegExNoData = '^[ ─┌┬┤├┐┼└┴┘]*$' | |
# This is used to match the phase line and exclude it. | |
# Also used to create an array of weather data for each date | |
$PhasesOfDay = @("Morning", "Noon", "Evening", "Night") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Hype { | |
param ( | |
[switch]$CleganeBowl, | |
[switch]$KingsMoot | |
) | |
New-Object psobject -Property ([ordered]@{ | |
CleganeBowl = $CleganeBowl | |
CleganeBowlIsPresent = $CleganeBowl.IsPresent | |
CleganeBowlBound = $PSBoundParameters.ContainsKey('CleganeBowl') | |
KingsMoot = $KingsMoot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This isn't tested much as I don't have the original data, but I've tested varios snippets, and they seem to work | |
# $GraylogUrl = "http://example.tld:12201/gelf" | |
$GraylogUdpPort = 12201 | |
$GraylogUdpHost = "example.tld" | |
$UDPclient = new-Object System.Net.Sockets.UdpClient | |
$UDPclient.Connect($GraylogUdpHost, $GraylogUdpPort) | |
$Enc = [system.Text.Encoding]::UTF8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Uri = "http://midnightfreddie.com/reddit/simpletable.html" | |
$InfoPage = Invoke-Webrequest -Uri $Uri | |
# Iterate over each <tbody> which contain all the body rows for each table | |
$InfoPage.ParsedHtml.getElementsByTagName("tbody") | ForEach-Object { | |
$Headers = $null | |
# Might need to uncomment the following line depending on table being parsed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Silliness. U0300 - U0036F are combining unicode characters | |
# https://en.wikipedia.org/wiki/Combining_Diacritical_Marks | |
$String = "The quick, brown fox jumped over the lazy dog" | |
$Combining = 0x0300 .. 0x036F | ForEach-Object { [char]$_ } | Sort-Object { Get-Random } | |
$i = 0 | |
($String.ToCharArray() | ForEach-Object { $_ -replace '[A-Za-z]', "`$0$($Combining[$i++])" }) -join "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dot-source function file | |
. .\BusinessDays.ps1 | |
Describe 'Get-IsWeekDay' { | |
@{ Date = "2016-05-15"; IsWeekDay = $false}, | |
@{ Date = "2016-05-16"; IsWeekDay = $true }, | |
@{ Date = "2016-05-17"; IsWeekDay = $true }, | |
@{ Date = "2016-05-18"; IsWeekDay = $true }, | |
@{ Date = "2016-05-19"; IsWeekDay = $true }, | |
@{ Date = "2016-05-20"; IsWeekDay = $true }, |