Skip to content

Instantly share code, notes, and snippets.

View dfch's full-sized avatar

Ronald Rink dfch

View GitHub Profile
@dfch
dfch / connection.cs
Last active May 8, 2017 01:04
Receiving SignalR messages from PowerShell
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Client;
using System.Collections.Concurrent;
using System.Net;
@dfch
dfch / SignalrClient.ps1
Created September 5, 2014 12:51
Receiving SignalR messages from PowerShell
$eventName = "receiveMessage";
Add-Type -Path ".\SignalRClient.dll"
$s = New-Object SignalRClient.Connection("http://localhost/", "commandhub");
$s.Start($eventName);
while($true) {
$s.TryDequeue($eventName)
Start-Sleep -seconds 1
}
# string TryDequeue(string eventName)
@dfch
dfch / jaydata-select2.js
Created September 13, 2014 09:01
[NoBrainer] Using JayData with jQuery select2 plugin in LightSwitch HTML
function searchData(svcUrl, data, searchTerm) {
var context = new LightSwitchApplication.ApplicationData({
name: 'oData',
oDataServiceHost: svcUrl
});
return context
.EntitySet
.filter(function (entity) {
return entity.Name.startsWith(this.q);
@dfch
dfch / rabbitmq-wrapper.cs
Last active August 29, 2015 14:06
Simple RabbitMQ Wrapper for PowerShell
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using RabbitMQ.Util;
@dfch
dfch / AddFuncensteinScreen.lsml.js
Last active August 29, 2015 14:06
[NoBrainer] Changing LightSwitch HTML Cascading choiceLists with JayData
// global - or wherever it suits you
var ctxApplicationData = "ctxApplicationData";
// somewhere at the very start of the application
$(function () {
var svcApplicationData = msls.application.rootUri + "/ApplicationData.svc";
$data.initService(svcApplicationData)
.then(function (context) {
// manage your data through context with JSLQ
console.log(svcApplicationData + ": we are here...");
@dfch
dfch / Invoke-CteraFileTransfer.ps1
Last active August 29, 2015 14:06
biz.dfch.PS.Storebox.Api: Invoke-CteraFileTransfer
// http://d-fens.ch/2013/11/27/biz-dfch-ps-storebox-api-invoke-cterafiletransfer/
// Check https://github.com/dfch/biz.dfch.PS.Storebox.Api for the complete repository of this module
function Invoke-CteraFileTransfer {
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High",
HelpURI='http://dfch.biz/PS/Storebox/Api/Invoke-CteraFileTransfer'
)]
[OutputType([string])]
Param (
@dfch
dfch / Invoke-SqlCmd.ps1
Created October 19, 2014 18:38
[biz.dfch.PS.System.Data] Invoke-SqlCmd without the overhead
# [biz.dfch.PS.System.Data] Invoke-SqlCmd without the overhead
# http://d-fens.ch/2013/11/26/biz-dfch-ps-system-data-invoke-sqlcmd-without-the-overhead
function Invoke-SqlCmd {
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="Medium",
HelpURI='http://dfch.biz/PS/System/Data/Invoke-SqlCmd/'
)]
Param (
@dfch
dfch / ExternalWFStubs-Part1.ps1
Last active August 29, 2015 14:08
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell (1)
# http://d-fens.ch/2013/12/05/vcac-dynamically-execute-scripts-in-externalwfstubs-workflows-with-powershell/
PS > $Machine.GetType().FullName
DynamicOps.ManagementModel.VirtualMachine
PS > $m.GetType().FullName
DynamicOps.ManagementModel.ManagementModelEntities
# script main
$Write-Host ("{0}: Processing Machine entity: '{1}'." -f $Machine.VirtualMachineID, $Machine.VirtualMachineName);
@dfch
dfch / ExternalWFStubs-Part2.ps1
Created November 4, 2014 06:50
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell (2)
# http://d-fens.ch/2013/12/05/vcac-dynamically-execute-scripts-in-externalwfstubs-workflows-with-powershell/
# Machine is the currently processed virtual machine
# Path is a default path where the scripts are located
# ScriptName is the name of the PowerShell script passed from the custom properties
# htScriptParam is a hastable containing parameter name and raw expression
$ScriptName = Join-Path -Path $Path -ChildPath $ScriptName;
if( !(Test-Path -Path $ScriptName) ) {
Write-Error ("ScriptName '{0}' does not exist." -f $ScriptName);
@dfch
dfch / Set-DomainMembership.ps1
Created November 4, 2014 07:11
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell - Set-DomainMembership.ps1
# http://d-fens.ch/2013/12/05/vcac-dynamically-execute-scripts-in-externalwfstubs-workflows-with-powershell/
PARAM (
[ValidateSet('EXAMPLE', 'SHAREDOP')]
[Parameter(Mandatory = $true, Position = 0)]
[string] $Domain
,
[Parameter(Mandatory = $true, Position = 1)]
[string] $Username
,