Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Busy

Tom Pažourek tompazourek

👨‍💻
Busy
Block or report user

Report or block tompazourek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View json-feed-example.json
{
"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 Jun 12, 2019
Helper to generate Object IDs for debugging (to identify the same object via a number)
View DebugHelper.cs
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 / SeqExportAllToJson.cs
Created Jan 12, 2019
Program that downloads data from a Seq instance and stores it in a JSON file (CLEF format)
View SeqExportAllToJson.cs
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 Aug 16, 2018
Numbers from 0 to 9999.
View Numbers.sql
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]),
View SequentialGuid.cs
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
View Rename SQL database.sql
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 Nov 1, 2017
Load items with all of their parent items as well.
View nodes-with-parents.sql
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 Oct 24, 2017
Database tables and rows
View tables_and_rows.sql
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'
@tompazourek
tompazourek / count_tables.sql
Created Oct 24, 2017
Count number of tables in MS SQL database
View count_tables.sql
SELECT COUNT(*) AS [TableCount] FROM [information_schema].[tables] WHERE [table_type] = 'BASE TABLE'
View refno.sql
SELECT CONCAT('ABC', REPLICATE('0',6-LEN(CAST(other_id as nvarchar(max)))), CAST(other_id as nvarchar(max)))
FROM [experiments].[dbo].[Table_1]
SELECT CONCAT('ABC', FORMAT(Other_Id, '000000'))
FROM [experiments].[dbo].[Table_1]
You can’t perform that action at this time.