Skip to content

Instantly share code, notes, and snippets.

View tompazourek's full-sized avatar
👨‍💻
Busy

Tom Pažourek tompazourek

👨‍💻
Busy
View GitHub Profile
public static class NullableExtension
{
public static bool TryGetValue<T>(this T? nullableValue, out T value) where T : struct
{
if (!nullableValue.HasValue)
{
value = default;
return false;
}
{
"version": "https://jsonfeed.org/version/1",
"title": "This is my feed title",
"home_page_url": "https://example.org/homepage",
"feed_url": "https://example.org/feed.json",
"description": "This is my feed description",
"user_comment": "This is a user comment",
"next_url": "https://example.org/feed.json?offset=1",
"icon": "https://example.org/icon.png",
"favicon": "https://example.org/favicon.ico",
@tompazourek
tompazourek / DebugHelper.cs
Created June 12, 2019 17:40
Helper to generate Object IDs for debugging (to identify the same object via a number)
using System;
using System.Runtime.CompilerServices;
public static class DebugHelper
{
private static readonly ConditionalWeakTable<object, object> _objectIds = new ConditionalWeakTable<object, object>();
private static int _lastObjectId;
private static readonly object _lock = new object();
public static string GetObjectId(object obj)
@tompazourek
tompazourek / feathericons.less
Last active February 2, 2019 23:34
Feather icons (http://colebemis.com/feather/) for Bootstrap
@charset "UTF-8";
@font-face {
font-family: "feather";
src: ~"url('@{icon-font-path}feather-webfont.eot')";
src: ~"url('@{icon-font-path}feather-webfont.eot?#iefix') format('embedded-opentype')",
~"url('@{icon-font-path}feather-webfont.woff') format('woff')",
~"url('@{icon-font-path}feather-webfont.ttf') format('truetype')",
~"url('@{icon-font-path}feather-webfont.svg#featherregular') format('svg')";
font-weight: normal;
@tompazourek
tompazourek / SeqExportAllToJson.cs
Created January 12, 2019 18:35
Program that downloads data from a Seq instance and stores it in a JSON file (CLEF format)
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Seq.Api;
namespace SeqExportAllToJson
{
internal class Program
{
@tompazourek
tompazourek / Numbers.sql
Last active August 16, 2018 12:49
Numbers from 0 to 9999.
WITH [Numbers] AS
(
SELECT
[Ones].[Number] +
10 * [Tens].[Number] +
100 * [Hundreds].[Number] +
1000 * [Thousands].[Number]
AS [Number]
FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) [Ones]([Number]),
(VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) [Tens]([Number]),
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Guids
{
public static class SequentialGuid
USE MASTER
ALTER DATABASE [DatabaseOldName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE [DatabaseOldName] MODIFY NAME = [DatabaseNewName]
ALTER DATABASE [DatabaseNewName] SET MULTI_USER
@tompazourek
tompazourek / nodes-with-parents.sql
Created November 1, 2017 09:47
Load items with all of their parent items as well.
WITH [NodesWithParents] AS
(
SELECT * FROM [Nodes] n WHERE n.[Id] IN (...)
UNION ALL
SELECT parent.* FROM [Nodes] parent
INNER JOIN [NodesWithParents] child ON child.[ParentNode_Id] = parent.[Id]
)
SELECT DISTINCT [Id] FROM [NodesWithParents]
@tompazourek
tompazourek / tables_and_rows.sql
Created October 24, 2017 13:12
Database tables and rows
SELECT
CONVERT(NVARCHAR(MAX), t.[table_schema]) AS [Owner],
CONVERT(NVARCHAR(MAX), t.[table_name]) AS [TableName],
MAX(i.[rows]) AS [RecordCount]
FROM
[sysindexes] i,
[information_schema].[tables] t
WHERE
t.[table_name] = OBJECT_NAME(i.[id])
AND t.[table_type] = 'BASE TABLE'