Skip to content

Instantly share code, notes, and snippets.

View WilliamBerryiii's full-sized avatar

Bill Berry WilliamBerryiii

View GitHub Profile
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- AIG architecture: x86
CMake Error at CMakeLists.txt:128 (add_subdirectory):
The source directory
C:/azure-iot-gateway-sdk/deps/azure-c-shared-utility
@WilliamBerryiii
WilliamBerryiii / EasyNetQAdvancedBusExample
Created April 22, 2016 05:05
Simple example of consuming an EasyNetQ Advanced Bus from F#
let messageHandlers () =
new Action<byte[], MessageProperties, MessageReceivedInfo>(fun message props receivedInfo ->
let envelope = message |> Encoding.UTF8.GetString |> Envelope.Parse
match Model.TryParse(envelope.Topic) with
| Some x ->
subject.OnNext ( pushToQueue x )
| None -> ()
)
let queue = bus.Advanced.QueueDeclare(rabbitConfig.Queue, passive = true)
@WilliamBerryiii
WilliamBerryiii / NantRunningNUnit3ForJenkins
Created April 20, 2016 05:02
Example of calling nunit3 from nant and exporting an nunit2 test results file.
<target name="test" depends="compile">
<copy file="src/ApplicationUnitTests/bin/${build.configuration}/App.config" tofile="src/Application.config" />
<exec program="nunit3-console.exe">
<arg value="src/Application.nunit" />
<arg value="--config:Release" />
<arg value="--result=TestResult.xml;format=nunit2" />
</exec>
<delete file="src/Application.config" />
</target>
@WilliamBerryiii
WilliamBerryiii / Set-ConnectionStringPassword
Created April 3, 2016 15:11
Setting a connection string password w/ password prompt
function Set-ConnectionStringPassword ($xml, $dbName, $dbUser, $connectionStringTemplate) {
$connString = New-Object System.Data.Common.DbConnectionStringBuilder
$conStringNodeSelector = $connectionStringTemplate -f $dbName
$connectionStringString = $xml.SelectSingleNode($conStringNodeSelector).connectionString
$connString.set_ConnectionString($connectionStringString)
# we might be using integrated security if so dont ask for pass
if(![string]::IsNullOrEmpty($connString.password)){
$prompt = 'What is the {0} password for user {1}?' -f $dbname, $($connString['$dbuser'])
$SecurePassword = Read-Host $prompt -AsSecureString
@WilliamBerryiii
WilliamBerryiii / hbasedatawriter.fs
Created February 29, 2016 23:15
Sample HBase Data Writer
let writeData (client:Hbase.Client) tableName dataColumn data =
let writePrams = new Dictionary<byte[],byte[]>()
let mutation = Collection.init [new Mutation ( Column = getBytes dataColumn, Value = getBytes data.Payload ) ] : List<Mutation>
let returnIdKeyedRow = new BatchMutation( Row = getBytes data.CompositeKey, Mutations = mutation )
let deptClassSubKeyedRow = new BatchMutation( Row = getBytes data.ReverseCompositeKey, Mutations = mutation )
let rows : List<BatchMutation> = Collection.init [returnIdKeyedRow; deptClassSubKeyedRow]
let result = client.mutateRows(getBytes tableName, rows, writePrams)
result
@WilliamBerryiii
WilliamBerryiii / GetNICSpeedInMB
Created January 10, 2016 20:07
Get NIC Link Speed in MB
Get-WmiObject -ComputerName localhost -Class Win32_NetworkAdapter |
Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } |
Select-Object -Property SystemName,Name,NetConnectionID`
,@{label="LinkSpeed(MB)";Expression={$_.Speed/1000000 -as [int]}}
@WilliamBerryiii
WilliamBerryiii / GetNICSpeedAsObject
Last active January 7, 2016 21:59
Modified StackOverflow Powershell Get NIC Speed
Get-WmiObject -ComputerName localhost -Class Win32_NetworkAdapter |
Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } |
Select-Object -Property SystemName,Name,NetConnectionID,Speed
@WilliamBerryiii
WilliamBerryiii / GetNICSpeedAsTable
Created January 7, 2016 21:26
StackOverflow Powershell Get NIC Speed
Get-WmiObject -ComputerName localhost -Class Win32_NetworkAdapter |
Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } |
Format-Table -Property SystemName,Name,NetConnectionID,Speed
@WilliamBerryiii
WilliamBerryiii / AlternateADUserGroupFlattenScanPsV2
Last active December 1, 2015 21:23
Active Directory User & Groups Flatten Scan for Powershell V2.0 with output flattened to a single element.
Try { Import-Module ActiveDirectory -ErrorAction Stop }
Catch { Write-Host "Unable to load Active Directory module."; Break; }
$hostname = [system.environment]::MachineName
$users = Get-ADUser -Filter * -Server $hostname
$users = $users | % {
$un = Get-ADUser "$_" -Properties * -Server $hostname
$groups = Foreach ($group in $un.MemberOf){
(Get-ADGroup $group -Server $hostname).Name
@WilliamBerryiii
WilliamBerryiii / ADUserGroupFlattenScanPsV2
Last active December 1, 2015 21:24
Active Directory User & Groups Flatten Scan for Powershell V2.0
Try { Import-Module ActiveDirectory -ErrorAction Stop }
Catch { Write-Host "Unable to load Active Directory module."; Break; }
$hostname = [system.environment]::MachineName
$users = Get-ADUser -Filter * -Server $hostname
$users | % {
$user = Get-ADUser "$_" -Properties * -Server $hostname
$Groups = Foreach ($group in $user.MemberOf){
(Get-ADGroup $group -Server $hostname).Name