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 / 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';
@maxisam
maxisam / setup-kubernetes-ubuntu-16.md
Created June 23, 2020 14:38 — forked from ruanbekker/setup-kubernetes-ubuntu-16.md
Install a 3 Node Kubernetes Cluster on Ubuntu 16

Master: Dependencies

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
@maxisam
maxisam / ngrx8-update.ts
Last active November 7, 2019 17:40
schematic for ngrx8
import { camelize, dasherize } from '@angular-devkit/core/src/utils/strings';
import { Rule, SchematicContext, Tree, UpdateRecorder } from '@angular-devkit/schematics';
import { tsquery } from '@phenomnomnominal/tsquery';
import { SyntaxKind } from 'typescript';
import * as ts from 'typescript';
// You don't have to export the function as default. You can also have more than one rule factory
// per file.
export function ngrx8Update(_options: any): Rule {
return (_tree: Tree, _context: SchematicContext) => {

Reading data before application startup in Angular 2

In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.

This is how the demonstration will load data:

a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';

b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.

@maxisam
maxisam / resources.md
Created April 2, 2018 20:00 — forked from paladique/resources.md
Getting started with Angular and .NET Core Web API
/* https://github.com/eisnerd/feedback-tool + github issues
Example:
$.feedbackGithub({
token: "16222221222128357fab95ec80b56a43c9a1868b429",
issues: {
repository: "tokland/feedback-test",
title: "feedback from user",
renderBody: (body) => "my own data\n" + body,
@maxisam
maxisam / Add-AspNetCoreEnvVarElems.ps1
Created February 20, 2018 16:28 — forked from markarnott/Add-AspNetCoreEnvVarElems.ps1
A powershell script to inject environmentVariable elements into aspNetCore Element in web.config for ASP.NET Core Module
#
# == Turn This ==
# <?xml version="1.0" encoding="utf-8"?>
# <configuration>
# <system.webServer>
# <handlers>
# <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
# </handlers>
# <aspNetCore processPath=".\MyCoreGizmo.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
# </system.webServer>
@maxisam
maxisam / .gitconfig
Created December 20, 2017 23:46 — forked from danny0838/.gitconfig
實用的 Git 配置值
[core]
quotepath = false # 中文檔名如實顯示而不轉碼
autocrlf = false # commit 及 checkout 時不根據作業系統轉換檔案的換行字元 (避免不小心改動原 repo 的換行字元)
safecrlf = false # 檢查文字類檔案是否混合了 CRLF 及 LF 換行字元 (搭配 autocrlf,這裡一起關閉)
ignorecase = false # 檔名大小寫不同時視為相異 (更動大小寫才能 commit)
whitespace = cr-at-eol # diff 時行尾 CRLF 不顯示 ^M
fileMode = false # 忽略檔案的 x 屬性 (for Windows)
symlinks = false # 忽略符號連結 (for Windows)
editor = /usr/bin/vim # 預設的文字編輯器 (for Linux)
[alias]