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;
<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 / 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]
@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
@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>
@jklemmack
jklemmack / gist:d3c958fbaff5e6c4fd31
Created June 28, 2015 20:45
Windows Universal code to read data from HIH6130
private void GetTemperatureAndHumidity(out double RH, out double T_C)
{
RH = 0d;
T_C = 0d;
try
{
byte[] write = new byte[] { (0x27 << 1) | 0x01 };
byte[] read = new byte[4];
// Inspired by http://www.phanderson.com/arduino/hih6130.html