Skip to content

Instantly share code, notes, and snippets.

View tom-erik's full-sized avatar

Tom-Erik Duestad tom-erik

  • SafeConsult
  • Oslo, Norway
View GitHub Profile
@tom-erik
tom-erik / semantic-commit-messages.md
Created July 13, 2023 07:46
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@tom-erik
tom-erik / migrate.sql
Created February 15, 2018 12:01
DB Migration objects
If Not Exists (Select 1 From INFORMATION_SCHEMA.ROUTINES Where SPECIFIC_SCHEMA = 'dbo' And SPECIFIC_NAME = 'fnIndexExists' And ROUTINE_TYPE = 'FUNCTION')
Begin
Exec('
Create Function [dbo].[fnIndexExists](@table_name nvarchar(max), @index_name nvarchar(max))
Returns bit
Begin
Return (Select Cast(Count(*) as Bit) From sys.indexes Where object_id = Object_Id(@table_name) AND name = @index_name);
End')
End
@tom-erik
tom-erik / split.sh
Created August 12, 2017 18:10
xargs split
# ps. writing this from my head so there is probably a few errors
# calculate total number of lines across the files
TOTAL_LINES=`cat *.json | wc -l`
# calculate what 1/4 would be (for a quad core box)
let SPLIT_SIZE=$TOTAL_LINES/4
# split the original input into files of this size, can end up with 5 files due
# to rounding of /4 but doesnt matter too much