Skip to content

Instantly share code, notes, and snippets.

@ArtemAvramenko
ArtemAvramenko / install.js
Last active June 22, 2024 14:34
Fastest install script for npm 7.0+, speed up npm ci
// Fastest install script for npm 7.0+
// usage: node install
const fs = require('fs');
const readLockFile = path => {
if (fs.existsSync(path)) {
const text = fs.readFileSync(path, { encoding:'utf8', flag:'r' });
const lockFile = JSON.parse(text);
delete lockFile.dependencies;
@ArtemAvramenko
ArtemAvramenko / openapi.yaml
Created September 1, 2021 14:50
OpenAPI inheritance
components:
schemas:
User:
title: User
description: User Model
type: object
properties:
id:
type: integer
firstName:
@ArtemAvramenko
ArtemAvramenko / localizeStub.ts
Created September 1, 2021 14:28
Angular $localize stub
function $localize(s: TemplateStringsArray) {
if (s.raw[0][0] === ':') {
const i = s[0].indexOf(':', 1)
if (i > 0) {
return s[0].substring(i + 1);
}
}
return s[0];
}
@ArtemAvramenko
ArtemAvramenko / vscode.settings.json
Created August 6, 2021 19:05
Visual Studio Code debug console background
{
"workbench.colorTheme": "Default Light+",
"workbench.colorCustomizations": {
"debugConsole.infoForeground": "#222222",
"debugConsole.errorForeground": "#cc0000",
"debugConsole.warningForeground": "#777700",
"debugConsole.sourceForeground": "#0088cc"
}
}
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using System;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
namespace Microsoft.Extensions.Hosting
{
@ArtemAvramenko
ArtemAvramenko / copy-url.user.js
Last active August 27, 2024 11:01
Copy URL UserScript
// ==UserScript==
// @include *
// @noframes
// @grant unsafeWindow
// @grant GM_registerMenuCommand
// @grant GM_setClipboard
// ==/UserScript==
GM_registerMenuCommand('Copy URL', () => {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
namespace tztest
{
class Program
{
private static XmlDocument LoadCldrXml(string path)
@ArtemAvramenko
ArtemAvramenko / max-integer-values.txt
Last active March 26, 2025 16:45
Max integer values
int 2 147 483 647 (2^32 / 2) - 2 billions
double 9 007 199 254 740 992 (2^53) - 9 quadrillions (millions of billions)
long 9 223 372 036 854 775 807 (2^64 / 2) - 9 quintillions (billions of billions)
decimal 79 228162514 264337593 543950335 (2^96) - 79 octillions (billions of billions of billions)
t/sql money 922 337 203 685 477 (2^63 / 1e4) - 900 trillions (millions of millions)
t/sql smallmoney 214 748 (2^31 / 1e4) - 200 thousands
t/sql numeric(38,4) 999999999..99 (1e34 - 1) - 9 decillion (millions of billions of billions of billions)
@ArtemAvramenko
ArtemAvramenko / CamelCaseConverter.cs
Created October 27, 2020 10:53
C# camel case coverter
public static string ToCamelCase(string text)
{
if (text != null)
{
var upperCount = 0;
while (upperCount < text.Length && char.IsUpper(text, upperCount))
{
upperCount++;
}
if (upperCount > 1 && upperCount < text.Length && char.IsLower(text, upperCount))
SELECT
sum(ddps.row_count)
FROM sys.indexes AS i
INNER JOIN sys.objects AS o ON i.OBJECT_ID = o.OBJECT_ID
INNER JOIN sys.dm_db_partition_stats AS ddps ON i.OBJECT_ID = ddps.OBJECT_ID
AND i.index_id = ddps.index_id
WHERE i.index_id < 2 AND o.is_ms_shipped = 0