Skip to content

Instantly share code, notes, and snippets.

View NBprojekt's full-sized avatar
:octocat:
Work smarter, not harder

Norbert Bartko NBprojekt

:octocat:
Work smarter, not harder
View GitHub Profile
@NBprojekt
NBprojekt / packCleanUp.py
Created August 26, 2019 08:32
This script is made for simple cleaning up of downloaded icon packages
# This script is made for simple cleaning up of downloaded icon packages
# - Remove meaningless chars in front of the name
# - Remove not needed folders
# - Move folder into 'packs' folder for better structure
import shutil, os, glob
path = input("Select pack name: ")
files = os.listdir(path + "/svg")
fileExtensions = ["eps", "license", "png", "psd", "svg"]
@NBprojekt
NBprojekt / errorImg.directive.ts
Last active October 10, 2019 11:25
Replace broken img with default img directive in Angular
// Usage:
// <img src="broken.jpg" default="placeholder.jpg">
import { Directive, Input } from '@angular/core'
@Directive({
selector: 'img[default]',
host: {
'(error)':'updateUrl()',
'[src]':'src'
@NBprojekt
NBprojekt / app.material.module.ts
Created September 5, 2019 12:29
All angular material 8 modules in alphabetic order
import { NgModule } from '@angular/core';
import {
MatAutocompleteModule,
MatBadgeModule,
MatBottomSheetModule,
MatButtonModule,
MatButtonToggleModule,
MatCardModule,
MatCheckboxModule,
MatChipsModule,
@NBprojekt
NBprojekt / enum.pipe.ts
Last active November 25, 2019 15:24
Pipe for Typescript 2.4 enum which contain string initializers
// Usage:
// <div *ngFor="let item of items | enum"> {{item.key}} | {{item.value}} </div>
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'enum'
})
export class EnumPipe implements PipeTransform {
transform(object: Object): Array<{ key: string, value: string }> {
@NBprojekt
NBprojekt / mat-badge-icon.directive.ts
Created October 10, 2019 11:23
Use font awesome icons in mat badge
import { Directive, ElementRef, Input, OnInit } from '@angular/core';
@Directive({
selector: '[matBadgeIcon]'
})
export class MatBadgeIconDirective implements OnInit{
@Input() matBadgeIcon: string;
@NBprojekt
NBprojekt / Dockerfile
Last active January 13, 2020 09:52
Dockerfile to host dotnet core apps like blazor (dotnet core 3.0)
# Create build img
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.sln .
COPY ./{PROJECT_NAME}/*.csproj ./{PROJECT_NAME}/
RUN dotnet restore
# Copy everything else and build app
@NBprojekt
NBprojekt / Dockerfile
Created January 6, 2020 11:59
Dockerfile to host dotnet core apps like blazor using IIS (dotnet core 3.0)
# Use iis as base image and install dotnet 3.0.1 hosting pack
FROM microsoft/iis as base
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
ADD https://download.visualstudio.microsoft.com/download/pr/32b71802-0b4d-4064-a7e6-083b5155d3b1/080cf60a5c06be4ed27e2eac6c693f2f/dotnet-hosting-3.0.1-win.exe "C:/setup/dotnet-hosting-3.0.1-win.exe"
RUN start-process -Filepath "C:/setup/dotnet-hosting-3.0.1-win.exe" -ArgumentList @('/install', '/quiet', '/norestart') -Wait
RUN Remove-Item -Force "C:/setup/dotnet-hosting-3.0.1-win.exe"
##############################################################################################################
@NBprojekt
NBprojekt / material-elevation.css
Last active December 10, 2020 16:47
Includes all material elevation classes
:root {
/* Just for theming purposes */
--mat-elevation-color: 0, 0, 0;
}
.mat-elevation-z0 {
box-shadow: 0 0 0 0 rgba(var(--mat-elevation-color), .2),
0 0 0 0 rgba(var(--mat-elevation-color), .14),
0 0 0 0 rgba(var(--mat-elevation-color), .12);
}

Collection of useful git commands

Show current branch

git branch --show-current

Empty commit to init branch

git commit --allow-empty -m "Init branch"
console.log(`
_ _ _ _
| | (_) | | | |
_ __ | |__ _ __ _ __ ___ _ ___| | _| |_
| '_ \\| '_ \\| '_ \\| '__/ _ \\| |/ _ \\ |/ / __|
| | | | |_) | |_) | | | (_) | | __/ <| |_
|_| |_|_.__/| .__/|_| \\___/| |\\___|_|\\_\\\\__|
| | _/ |
|_| |__/
`);