Skip to content

Instantly share code, notes, and snippets.

View kstrauss's full-sized avatar

Karl Strauss kstrauss

  • Realgy LLC
  • Hartford area, CT
View GitHub Profile
@kstrauss
kstrauss / ESQuery_ForGitHubIssue900.linq
Created April 26, 2016 18:11
Reproduction code for EventStore Issue #900
<Query Kind="Program">
<Connection>
<ID>e8afa357-aae4-40ae-a4ad-e4783f38f696</ID>
<Server>rdbtest2012</Server>
<Database>PackageMonitorReadModel_SGSpike-Main</Database>
<ShowServer>true</ShowServer>
</Connection>
<NuGetReference>EventStore.Client</NuGetReference>
<NuGetReference>Newtonsoft.Json</NuGetReference>
<NuGetReference>Rx-Linq</NuGetReference>
@kstrauss
kstrauss / PushToEventHub.ps1
Created July 12, 2016 12:50
Publish to an azure event hub from powershell
$ehName = "powershellposttest" # hub name
$ehNameSpace = "RFGateLgEUS" # namespace
$keyname = "senderPolicy" # name of the policy
$key = "yourKEY"
# Load the System.Web assembly to enable UrlEncode
[Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null
$URI = "{0}.servicebus.windows.net/{1}" -f @($ehNameSpace,$ehName)
$encodedURI = [System.Web.HttpUtility]::UrlEncode($URI)
@kstrauss
kstrauss / shrug.sql
Last active September 30, 2016 03:00
example function to categorize usage to different time of use pricing. Not complete because the data may cross over multiple categories. For example you might get usage from 12:31-1:01. 1 minute is at the peak rate and the other 29 minutes is on the shoulder rate.
alter function Shrug (@d as datetime)
returns varchar(50)
begin
declare @dw int , @hh int, @mi int
Set @dw = (select datepart(dw,@d))
set @hh = (select datepart(hh,@d))
set @mi = (select datepart(mi,@d))
-- week day & 13:00 up to and including 18:00 == peak
-- offPeak any day before 8:00 and after 22
-- shoulder anything else
@kstrauss
kstrauss / ObservableDistribution.linq
Created October 7, 2016 17:28
Observable bucket with counts and a little graph
<Query Kind="Program">
<Connection>
<ID>0515683c-2a33-40ff-8c59-990ea709b2c8</ID>
<Persist>true</Persist>
<Server>rdbtest2012</Server>
<Database>PackageMonitorReadModel_SGSpike-Main</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.DataVisualization.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
@kstrauss
kstrauss / garbage_priv.key
Created October 21, 2016 15:11
nsoftware example trying to sign a document. It doesn't seem to work either using the builtin provider or using the GnuPG_Provider provider.
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1.4.11 (MingW32)
lQO9BFgKLY0BCADo95cLyH71EwTKR0ExNHSldu9As0hqH0lTmURIghWbPhQ1fmdV
QiXb05FFz8uKCOkc5pLleESij8LkNzc+eEafc/yM+1nUF6COlRik/h2gajJciknG
fWtzWaRj2MX4X2UhfG9+VmUXk+eHInnW8N3qDXg6KZKJm1Gjtasko+v0x/MsHr5S
MCdRbFD8PKotT80QnDwN01cxmw7QULXTyKPa4KkDXmDebaJwEhUCxEzE+NhqWlxP
KUyjqOMdfHG8pN9hbHl5LtjHqukuZCN/zW7XlNxPIorDpeT68hI3PDILHfF3bTbs
rtjm2qa/rNXkfz/UmK7Z4CwuGLO2K7bIlQ1bABEBAAH+AwMCBfgwDxVJWehgmZkP
dgK0ImaDsFPKDEoccs8gnmrVM4ONA1y9cehyR9W/VdJBQuN+Jbj21158+bDjn+uM
dir -recurse -filter *.csproj | %{
Edit-Reference -path $_.fullName -dllRef '$(SolutionDir)\packages\Realgy.ExternalIntegration.Infrastructure.GitHash.1.0.1\lib\net452\Realgy.ExternalIntegration.Infrastructure.GitHash.dll' -refName 'Realgy.ExternalIntegration.Infrastructure.GitHash, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL'
}
@kstrauss
kstrauss / ExtendDeal.sql
Last active June 7, 2018 15:23
Used for resnew, so that you can add months for a preset. It does things in bulk. This can happen because all months need to be created for each agreement type (or preset). So presets can be found at: select * from splr_preset, which defines what are the standard details for this "preset" or agreement type. Related to this should be a month list…
begin tran
declare @origDealId int
set @origDealId=44439
select * from vw_active_contract_deal_meters where deal_ik=@origDealId
-- declare variables for stored procedure
declare @contract_ik int
declare @deal_agent_ik int
declare @deal_affiliate_usr_ik int
declare @deal_splr_preset_ik int
declare @deal_splr_srvcplan_ik int
@kstrauss
kstrauss / EarlyWarning.cs
Created June 19, 2018 14:38
returns an observable that provides the first in a window and lets you know when the window closes and what was in the window
void Main()
{
var closer = new Subject<Tuple<WindowState, IList<long>>>();
closer.Select(c => {
if (c.Item1 == WindowState.Open)
{
return $"Should email, with an event of {c.Item2.Single()}";
}
else
@kstrauss
kstrauss / Test.graphviz
Created June 28, 2018 20:26
Test Process
digraph G {
graph [fontsize=10 fontname="Verdana" compound=true];
node [shape=record fontsize=10 fontname="Verdana"];
subgraph cluster_Development {
style=filled;
color=lightgrey;
label = "Development";
ReadSpecs -> PhysicalSentIntegration;
ReadSpecs -> PhysicalReceivedIntegration;
@kstrauss
kstrauss / LauraSimpleMatch.ps1
Last active September 27, 2018 14:08
a dumb way of matching up filenames to a list of names on the clipboard.
<#
https://gist.github.com/kstrauss/eb99f398d191426038067ab15a6a951a
Get filenames of PDF files, which are supposed to match the customer names in the sales Requests/Commission reports.
Potentially this should be limited to only a set of files from a certain period ??
#>
Cd 'Z:\CUSTOMER SERVICE\Customer Executed Contracts\ENDURE MARKETING'
$fnames = dir *.pdf | %{ $_.basename}
<#
Go copy the customer names you want to compare against. (i.e. go to excel and select the customer