Skip to content

Instantly share code, notes, and snippets.

View jklemmack's full-sized avatar

Johann Klemmack jklemmack

View GitHub Profile
using Microsoft.SqlServer.TransactSql.ScriptDom;
using ServiceStack.OrmLite.SqlServer;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
@jklemmack
jklemmack / client.cs
Last active July 5, 2022 20:50
WCF Tutorial - Basic Interprocess Communication
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
namespace WCFClient
{
[ServiceContract]
public interface IStringReverser
{
[OperationContract]
<Query Kind="Program">
<NuGetReference>MedallionShell</NuGetReference>
<Namespace>System.Threading.Tasks</Namespace>
<Namespace>Medallion.Shell</Namespace>
<Namespace>Medallion.Shell.Streams</Namespace>
</Query>
DumpContainer dc;
async Task Main()
{ var input = @"D:\Temp\fieldtest.mxf".Dump("input file");
<#
# Run these two lines to download the Microsoft Powershell Tools.
Project URL: https://github.com/Microsoft/ReportingServicesTools
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/ReportingServicesTools/master/Install.ps1)
#>
<#
# Run these two lines to download the Microsoft Powershell Tools.
Project URL: https://github.com/Microsoft/ReportingServicesTools
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Invoke-Expression (Invoke-WebRequest https://raw.githubusercontent.com/Microsoft/ReportingServicesTools/master/Install.ps1)
#>
@jklemmack
jklemmack / gist:77d966e250502f6b4b8bf253ca6a097a
Last active June 28, 2017 00:36 — forked from witwall/gist:5334142
Here’s the code to replace images in PDFs, in Java and C#. It will replace the first image in the first page.
PdfReader pdf = new PdfReader("in.pdf");
PdfStamper stp = new PdfStamper(pdf, new FileOutputStream("c:\\out.pdf"));
PdfWriter writer = stp.getWriter();
Image img = Image.getInstance("image.png");
PdfDictionary pg = pdf.getPageN(1);
PdfDictionary res =
(PdfDictionary)PdfReader.getPdfObject(pg.get(PdfName.RESOURCES));
PdfDictionary xobj =
(PdfDictionary)PdfReader.getPdfObject(res.get(PdfName.XOBJECT));
if (xobj != null) {
@jklemmack
jklemmack / SSORMLiteTest.cs
Last active June 10, 2016 03:09
Example of inconsistent boolean clause behavior in ServiceStack ORMLite 4.0.58
using ServiceStack.DataAnnotations;
using ServiceStack.OrmLite;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SSOrmLiteTest

This choropleth uses a threshold scale for quantization, mapping arbitrary slices of a continuous domain to discrete values in the range. Unemployment rates ranging from 2 to 10% are quantized into different shades of purple.

var color = d3.scale.threshold()
    .domain([.02, .04, .06, .08, .10])
    .range(["#f2f0f7", "#dadaeb", "#bcbddc", "#9e9ac8", "#756bb1", "#54278f"]);
@jklemmack
jklemmack / gist:09957fb0e05cf13181cd
Last active September 11, 2015 16:52 — forked from migajek/gist:dede8e9184a087e19bd9
Angular + ServiceStack's SSE
factory('sse', ['$rootScope', '$http', function($rootScope, $http) {
// https://gist.github.com/migajek
var splitOnFirst = function (s, c) { if (!s) return [s]; var pos = s.indexOf(c); return pos >= 0 ? [s.substring(0, pos), s.substring(pos + 1)] : [s]; };
return {
start: function(handlers) {
var opt = {};
var sse = new EventSource('/event-stream');
sse.addEventListener('message', function(e) {
var parts = splitOnFirst(e.data, ' ');
var selector = parts[0];
@jklemmack
jklemmack / index.html
Last active September 10, 2015 19:16 — forked from insin/index.html
Export a <table> to Excel - http://bl.ocks.org/insin/1031969
<!DOCTYPE html>
<html>
<head>
<title>tableToExcel Demo</title>
<script src="tableToExcel.js"></script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>