Skip to content

Instantly share code, notes, and snippets.

View jklemmack's full-sized avatar

Johann Klemmack jklemmack

View GitHub Profile
@insin
insin / index.html
Last active February 8, 2024 15:14
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>
anonymous
anonymous / _Layout.cshtml
Created April 17, 2012 16:31
Using MiniProfiler for MVC AND Ajax with ServiceStack
@Html.Raw(HttpUtility.HtmlDecode(Profiler.RenderIncludes().ToString()))
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
@gustavohenke
gustavohenke / svg2png.js
Created February 18, 2014 15:27
SVG to PNG
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@migajek
migajek / gist:dede8e9184a087e19bd9
Last active June 1, 2016 12:22
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];
@scottmcarthur
scottmcarthur / ServiceStackIsolatedAppHostTest.cs
Created September 25, 2014 15:34
ServiceStack AppHost Running in it's own AppDomain for Tests
using System;
using ServiceStack;
using System.Runtime.Remoting;
using NUnit.Framework;
namespace MyApp.Tests
{
public class AppHost : AppSelfHostBase
{
public AppHost(): base("My ServiceStack Service", typeof(AppHost).Assembly)
@belsrc
belsrc / gist:672b75d1f89a9a5c192c
Last active April 15, 2023 15:13
Simple Vue.js filters that I usually need
/**
* Changes value to past tense.
* Simple filter does not support irregular verbs such as eat-ate, fly-flew, etc.
* http://jsfiddle.net/bryan_k/0xczme2r/
*
* @param {String} value The value string.
*/
Vue.filter('past-tense', function(value) {
// Slightly follows http://www.oxforddictionaries.com/us/words/verb-tenses-adding-ed-and-ing
var vowels = ['a', 'e', 'i', 'o', 'u'];
<#
.SYNOPSIS
Resize an image
.DESCRIPTION
Resize an image based on a new given height or width or a single dimension and a maintain ratio flag.
The execution of this CmdLet creates a new file named "OriginalName_resized" and maintains the original
file extension
.PARAMETER Width
The new width of the image. Can be given alone with the MaintainRatio flag
.PARAMETER Height
@weipah
weipah / import-portatour.ps1
Last active March 4, 2024 22:34
PowerShell V3 Multipart/formdata example with REST-API (Invoke-RestMethod)
function Import-Portatour {
param (
[parameter(Mandatory=$True,Position=1)] [ValidateScript({ Test-Path -PathType Leaf $_ })] [String] $FilePath,
[parameter(Mandatory=$False,Position=2)] [System.URI] $ResultURL
)
# CONST
$CODEPAGE = "iso-8859-1" # alternatives are ASCII, UTF-8
# We have a REST-Endpoint
$RESTURL = "https://my.portatour.net/a/api/ImportCustomers/"
@cakriwut
cakriwut / ServiceBaseExtensions.cs
Created December 29, 2015 14:58
ServiceStack Extensions to POST multiple files along with dto.
///<summary>
/// ServiceClient Base Extensions
/// Author: Riwut Libinuko
/// Created Date: 29/12/2015
/// Website : http://blog.libinuko.com
/// Copyright(c) 2015
/// Use PostFilesWithRequest<TResponse>(...) , to POST metadata and multiple files attachment in single request
///</summary>
public static class ServiceClientBaseExtensions
{
@robmathers
robmathers / groupBy.js
Created October 25, 2018 23:18
A more readable and annotated version of the Javascript groupBy from Ceasar Bautista (https://stackoverflow.com/a/34890276/1376063)
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by
// reduce runs this anonymous function on each element of `data` (the `item` parameter,
// returning the `storage` parameter at the end
return data.reduce(function(storage, item) {
// get the first instance of the key by which we're grouping
var group = item[key];
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it
storage[group] = storage[group] || [];