Skip to content

Instantly share code, notes, and snippets.

View brokenthorn's full-sized avatar
🏠
Working from home

Paul-Sebastian Manole brokenthorn

🏠
Working from home
View GitHub Profile
@brokenthorn
brokenthorn / settings.json
Last active August 21, 2023 09:02
My VS Code Settings 05.05.2023
{
"editor.fontFamily": "'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace",
"editor.fontSize": 18,
"editor.fontWeight": "200",
"editor.lineHeight": 1.66,
"terminal.integrated.fontFamily": "'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace",
"terminal.integrated.fontSize": 14,
"terminal.integrated.fontWeight": "300",
@brokenthorn
brokenthorn / filter-by.pipe.ts
Created July 21, 2021 16:03
Angular Pipe Snippet for Recursive Filter Object Properties By Term with optional limit to a single property
import {Injectable, Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'filterBy',
pure: true
})
@Injectable()
export class FilterByPipe implements PipeTransform {
/**
@brokenthorn
brokenthorn / SqlDataReader_To_CSV_Using_CsvHelper_Library.cs
Created July 11, 2021 00:29
In this C# Gist, a CsvHelper.CsvWriter is used to asynchronously write the results of a SQL query to a CSV file without worrying about each column's data type.
try
{
await using var sqlDataReader = await sqlCommand.ExecuteReaderAsync(cancellationToken);
await using var streamWriter = new StreamWriter($"{reportName}_{startDate:dd-MM-yyyy}-{endDate:dd-MM-yyyy}.csv");
await using var csvWriter = new CsvWriter(streamWriter, _csvConfiguration);
var columnSchema = sqlDataReader.GetColumnSchema();
var columnCount = columnSchema.Count;
// write headers to CSV:
@brokenthorn
brokenthorn / patch-edit.rb
Created February 22, 2021 08:52
Create display override file to force Mac OS X to use RGB mode for External Displays
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for External Displays
# see http://embdev.net/topic/284710
#
# Update 2013-06-24: added -w0 option to prevent truncated lines
# Copy the folder that appears to sudo mkdir -p /Library/Displays/Contents/Resources/Overrides
require 'base64'
@brokenthorn
brokenthorn / Link.tsx
Created September 29, 2020 11:44
Partially converted TSX version of Material UI wraper for Next.js Link component
@brokenthorn
brokenthorn / WIP Schema.sql
Created September 21, 2020 19:26
WIP Schema
-- Start Migrations
-- Migration 20200921191728-mig-1
CREATE TABLE "public"."User" (
"id" SERIAL,
"email" text NOT NULL ,
"firstName" text NOT NULL ,
"middleName" text ,
"lastName" text NOT NULL ,
PRIMARY KEY ("id")
@brokenthorn
brokenthorn / README.md
Last active September 14, 2020 14:54
Restartable debugging for TypeScript within Visual Studio Code (vscode) using nodemon and ts-node

Info

Inspiration was taken from Eduardo Rabelo - https://eduardorabelo.me - from this article: https://dev.to/oieduardorabelo/nodejs-with-typescript-debug-inside-vscode-and-nodemon-23o7

To start debugging, you need to first start the dev:debug npm script with npm run dev:debug, then run the Node: Nodemon launch configuration from VSCode, in order to attach the debugger to the app process.

Pick the nodemon process when prompted, the one that should look like npx nodemon --inspect src/index.ts. It's the process that stays alive and restarts the app process when you make changes (of course it first feeds the *.ts code to ts-node for transpilation because of that node --require ts-node/register line in nodemon.json).

@brokenthorn
brokenthorn / UserRegistrationForm.vue
Last active June 20, 2020 20:09
Vue + Vuetify 2.x User Registration Form Component
<template>
<v-card id="register-form-card">
<v-form ref="form" v-model="valid" @keyup.native.enter="submit">
<v-container>
<v-row no-gutters>
<v-col>
<v-alert color="error" :value="responseStatus !== ''">{{
responseStatus
}}</v-alert>
</v-col>
@brokenthorn
brokenthorn / UserAuthForm.vue
Last active June 20, 2020 20:05
Vue + Vuetify User Login + Auth Form Component
<template>
<v-card id="login-form-card">
<v-form ref="form" v-model="valid" @keyup.native.enter="submit">
<v-container>
<v-row no-gutters>
<v-col>
<v-alert color="error" :value="responseStatus !== ''">{{
responseStatus
}}</v-alert>
</v-col>
@brokenthorn
brokenthorn / romanian-cif-validate.js
Last active January 24, 2024 09:00
Functie Javascript pentru validarea CIF (Cod Identificare Fiscala) / CUI (Cod Unic Identificare)
/**
* Validates if a string conforms to a valid Romanian Fiscal Code.
*
* See Romanian Law no. 359 from 8 September 2004.
* @param v {string} input string to be validated
* @returns {string|boolean} `true` if the input is a valid CIF or an error message,
* describing where validation failed
*/
function validateRomanianCIF (v) {
if (typeof v !== 'string') {