Skip to content

Instantly share code, notes, and snippets.

View MPrtenjak's full-sized avatar

Matjaž Prtenjak MPrtenjak

View GitHub Profile
record FilePath
{
public string Path { get; }
public FilePath(string path) =>
Path = string.IsNullOrWhiteSpace(path)
? throw new ArgumentException("path cannot be null or empty")
: System.IO.Path.GetInvalidPathChars().Intersect(path).Any()
? throw new ArgumentException("Path contains illegal characters")
: System.IO.Path.GetFullPath(path.Trim());
@MPrtenjak
MPrtenjak / .htaccess
Last active August 28, 2022 13:08
Apache .htaccess file for running Blazor Web App
<IfModule mod_headers.c>
# Serve brotli compressed files if they exist and the client accepts brotli.
RewriteCond "%{HTTP:Accept-encoding}" "br"
RewriteCond "%{REQUEST_FILENAME}\.br" "-s"
RewriteRule "^(.*)\.(js|json|css|dll|dat|blat|wasm)$" "$1\.$2\.br" [QSA]
# Serve gzip compressed files if they exist and the client accepts gzip.
RewriteCond "%{HTTP:Accept-encoding}" "gz"
RewriteCond "%{REQUEST_FILENAME}\.gz" "-s"
RewriteRule "^(.*)\.(js|json|css|dll|dat|blat|wasm)$" "$1\.$2\.gz" [QSA]
FUNCTION TransformCDATA(source_document XMLTYPE)
RETURN XMLTYPE
IS
/*
PLSQL (ORACLE) function to transform XML document with CDATA sections
into document without CDATA sections
*/
x_xslt XMLTYPE;
x_trans XMLTYPE;
<!--
Transforming XML with CDATA sections into XML without CDATA sections
-->
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
@MPrtenjak
MPrtenjak / Bitstamp.php
Last active December 22, 2018 21:20
Bitstamp API V2, writen in PHP
<?php
namespace Bitstamp;
class Bitstamp
{
const BASE_V1_API_URL = 'https://www.bitstamp.net/api/';
const BASE_V2_API_URL = 'https://www.bitstamp.net/api/v2/';
private $key;
@MPrtenjak
MPrtenjak / TSet.cls
Created July 26, 2018 07:31
VBA utilities
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "TSet"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
@MPrtenjak
MPrtenjak / ResizeDetector.js
Last active July 16, 2018 05:55
CSS grid change detection (detect responsive breakpoints)
'use strict'
/*
bootstrap 4.0 grid system
*/
const bootstrapGrid = [
{ name: "xs", size: 576 },
{ name: "sm", size: 768 },
{ name: "md", size: 992 },
{ name: "lg", size: 1200 },