Skip to content

Instantly share code, notes, and snippets.

View henningjensen's full-sized avatar

Henning Jensen henningjensen

View GitHub Profile
@henningjensen
henningjensen / CacheController.cs
Created February 4, 2022 09:08
dotnet api controller run long running job - populate cache example
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
namespace MyNamespace.Controllers;
[Route("/api/cache")]
[ApiController]
public class CacheController : ControllerBase
{
@henningjensen
henningjensen / print.sh
Created November 22, 2017 21:12
Printing multiple files in Ubuntu with Nautilus script
#!/bin/bash
#
# print.sh
#
# credits original script:
# http://www.frenssen.be/2010-05-09-printing-a-file-from-the-right-click-context-menu-in-nautilus/
#
# Print files from the right-click context menu in Nautilus.
# Place this script in ~/.local/share/nautilus/scripts/
@henningjensen
henningjensen / exiftool.md
Last active November 17, 2018 20:45
exiftool cheat sheat

Rename files according to date taken

  • rename according to DateTimeOriginal-tag

  • lowercase the file extension

  • recursive from current directory

  • move to output directory in a date hierarchy

    $ exiftool -progress "-filename<DateTimeOriginal" -d "output/%Y/%Y-%m/%Y-%m-%d_%H%M%S%%-c.%%le" -r .

MP4 video files from cellphone

@henningjensen
henningjensen / 0_reuse_code.js
Created December 5, 2016 11:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@henningjensen
henningjensen / index.html
Created December 9, 2015 09:56
Kartverket - Leaflet with UTM33 projection - add markers and features.
<div id="map" width="500" height="500"></div>
<script type="text/javascript">
(function () {
L.Icon.Default.imagePath = '/Content/img/leaflet/';
var crs = L.CRS.proj4js('EPSG:32633', '+proj=utm +zone=33+ellps=WGS84 +datum=WGS84 +units=m +no_defs', new L.Transformation(1, 2500000, -1, 9045984));
crs.scale = function (zoom) {
return 1 / (21674.7100160867 / Math.pow(2, zoom));
@henningjensen
henningjensen / ItemsChoiceType23.cs
Created November 13, 2015 08:37
Geonorge - Search filter enum
namespace www.opengis.net
{
[GeneratedCode("xsd", "4.0.30319.17929")]
[XmlType(Namespace = "http://www.opengis.net/ogc", IncludeInSchema = false)]
public enum ItemsChoiceType23
{
And,
BBOX,
Beyond,
Contains,
@henningjensen
henningjensen / searchfilter.cs
Created November 13, 2015 08:34
Geonorge - CSW search filter
var searchFilter = new object[] {
new PropertyIsLikeType {
PropertyName = new PropertyNameType { Text = new[] { "Type" } },
Literal = new LiteralType { Text = new[] { "service" } }
}
};
var searchFilterNames = new[] { ItemsChoiceType23.PropertyIsLike };
@henningjensen
henningjensen / request.cs
Created November 12, 2015 11:40
Geonorge - CSW search filter organisation and type
var searchFilter = new object[]
{
new BinaryLogicOpType()
{
Items = new object[]
{
new PropertyIsLikeType
{
PropertyName = new PropertyNameType {Text = new[] {"OrganisationName"}},
Literal = new LiteralType {Text = new[] { "Kartverket" }}
@henningjensen
henningjensen / request.xml
Created November 12, 2015 11:37
Geonorge - CSW Search for services from Kartverket
<?xml version="1.0" encoding="utf-8"?>
<csw:GetRecords xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:gts="http://www.isotc211.org/2005/gts" service="CSW" version="2.0.2" resultType="results" outputSchema="csw:Record" maxRecords="20" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2">
<csw:Query typeNames="csw:Record">
<csw:ElementSetName>full</csw:ElementSetName>
<csw:Constraint version="1.1.0">
<Filter xmlns="http://www.opengis.net/ogc">
<And>
<PropertyIsLike>
<PropertyName>OrganisationName</PropertyName>
<Literal>Kartverket</Literal>
@henningjensen
henningjensen / make-cabinet.bat
Last active September 17, 2015 10:28
make cab file
dir /b >files.txt
makecab /d "CabinetName1=test.cab" /f files.txt