Skip to content

Instantly share code, notes, and snippets.

View maxisam's full-sized avatar
💭
I may be slow to respond.

Sam Lin maxisam

💭
I may be slow to respond.
View GitHub Profile
@maxisam
maxisam / GenericHostWithEf.csproj
Created August 28, 2021 18:56 — forked from panicoenlaxbox/GenericHostWithEf.csproj
.NET Core Generic host with EF Core
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
@maxisam
maxisam / bash_strict_mode.md
Created August 9, 2021 16:42 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@maxisam
maxisam / interview.md
Created May 29, 2021 09:54 — forked from bcabanes/interview.md
Interview questions Angular

Frontend interview questions

First, you should ask for his/her Github username and check public repositories.

Note: Keep in mind that many of these questions are open-ended and could lead to interesting discussions that tell you more about the person's capabilities than a straight answer would.

General

  • What Javascript Frameworks do you know? Which one do you like? Why?
  • What is the atomic design?

Coined by Brad Frost, Atomic Design is a methodology that involves breaking a website layout down into its basic components, which are then reused throughout the site. You have Atoms => Molecules => Organisms => Templates => Pages.

  • Can you name two programming paradigms important for JavaScript app developers?

Angular Universal (Webpack bundle + Docker deploy)

Tested with angular@5.

Install deps

npm i @angular/platform-server @nguniversal/express-engine @nguniversal/module-map-ngfactory-loader express @types/express ts-loader@3 rimraf --save-dev

Update src/app/app.module.ts

@maxisam
maxisam / hg-truncate-and-sync.sh
Created October 9, 2020 17:43 — forked from jsoriano/hg-truncate-and-sync.sh
Uses hg convert to truncate a repository from an initial revision. If no revision is specified, the whole repository is converted. It optionally uses an intermediate repository (cache) in case the source repository can be written during the convert operation.
#!/bin/bash
#
# Uses hg convert to strip a repository from <start revision>
# If no revision is specified, the whole repository is converted.
# Optionally a "cache" repository can be used, to be sure that the
# source repository is not written during the convert operation.
#
while getopts "r:s:d:c:h?" opt; do
case $opt in
@maxisam
maxisam / clean_git_repository.bash
Created September 14, 2020 04:03 — forked from ymollard/clean_git_repository.bash
Clean a git repository by deleting history and data of old deleted files
#!/bin/bash
# This script, executed at the root of a git repository, deletes traces of every old file in this repository, index + blob on all branches
# It can take 10-30 minutes to run and will print regular warning stating than some references are unchanged
# time ./clear_git_repositor.bash >cleaning.log
# We need several passes to clean files renamed multiple times (git log --find-renames prevents its deletion for each renaming)
# MAXIMUM_PASSES should be more than the maximum number of renamings/movings for any file, if not then we might keep some traces of former files
MAXIMUM_PASSES=10 # Maximum number of passes
@maxisam
maxisam / multiple_ssh_setting.md
Created September 9, 2020 19:40 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@maxisam
maxisam / kubernetes_pods_docker_disk_usage.md
Created August 23, 2020 19:52 — forked from epcim/kubernetes_pods_docker_disk_usage.md
docker disk space introspection kubernetes docker overlay

identify big pods/containers

investigage big files

DST=/mnt
find /var/lib -type f -size +1G -exec ls -lh {} \; | tee  $DST/bigfiles_var_lib_$(date "+%H%M").log
find /var/lib -type f -size +1G -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' | sort -rh > $DST/bigfiles_var_lib_$(date "+%H%M").sorted.log

misbehave processes

@maxisam
maxisam / monzo-alertmanager-config.yaml
Created August 4, 2020 04:06 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@maxisam
maxisam / server.ts
Created July 30, 2020 03:17 — forked from kgajera/server.ts
Angular Express Server with Redis Caching
import 'zone.js/dist/zone-node';
import { APP_BASE_HREF } from '@angular/common';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { existsSync } from 'fs';
import { join } from 'path';
import * as redis from 'redis';
import { AppServerModule } from './src/main.server';