Skip to content

Instantly share code, notes, and snippets.

Avatar

Ronald Rink dfch

View GitHub Profile
@dfch
dfch / connection.cs
Last active May 8, 2017
Receiving SignalR messages from PowerShell
View connection.cs
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 Sep 5, 2014
Receiving SignalR messages from PowerShell
View SignalrClient.ps1
$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 Sep 13, 2014
[NoBrainer] Using JayData with jQuery select2 plugin in LightSwitch HTML
View jaydata-select2.js
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 Aug 29, 2015
Simple RabbitMQ Wrapper for PowerShell
View rabbitmq-wrapper.cs
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 Aug 29, 2015
[NoBrainer] Changing LightSwitch HTML Cascading choiceLists with JayData
View AddFuncensteinScreen.lsml.js
// 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 Aug 29, 2015
biz.dfch.PS.Storebox.Api: Invoke-CteraFileTransfer
View Invoke-CteraFileTransfer.ps1
// 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 Oct 19, 2014
[biz.dfch.PS.System.Data] Invoke-SqlCmd without the overhead
View Invoke-SqlCmd.ps1
# [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 Aug 29, 2015
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell (1)
View ExternalWFStubs-Part1.ps1
# 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 Nov 4, 2014
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell (2)
View ExternalWFStubs-Part2.ps1
# 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 Nov 4, 2014
vCAC: Dynamically execute Scripts in ExternalWFStubs Workflows with PowerShell - Set-DomainMembership.ps1
View 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
,