Skip to content

Instantly share code, notes, and snippets.

View myclau's full-sized avatar

Matthias Lau myclau

View GitHub Profile
@myclau
myclau / install_WSL_with_ubuntu.ps1
Created October 30, 2018 07:53
Script for install WSL and ubuntu (for this is version 18.04)
$featurename='Microsoft-Windows-Subsystem-Linux'
$Ubuntu_APK_URL="https://aka.ms/wsl-ubuntu-1804"
$Distro = 'Ubuntu-18.04'
$EXEName = 'ubuntu1804.exe'
function Exit_Wait(){
if($needRestart){
Write-Warning 'Please restart computer and run the script again!!!'
}
@myclau
myclau / Rancher 2.0 related script
Last active November 6, 2018 11:39
Rancher 2.0 related script
@myclau
myclau / Docker related script or Dockerfile
Last active November 15, 2018 05:56
library for store usually template for fast implement new docker image or local debug.
@myclau
myclau / copy_folderfiles_with_corrupt_files.ps1
Last active November 20, 2018 11:14
when copy files using windows ,sometimes will stuck forever, if file is corrupted expecially on sdcard, this script will help for skip those files and save which file is corrupt so if you stopped and run the copy again will not hit to the corrupt file again, but currently only support single folder will files and will skip subfolder
#Setup Source and Destination
$in="C:\test\logs"
$out = "C:\sdcard\test\logs"
$sourcedir = get-childitem -File "$in"
$destinationdir = Get-ChildItem -File "$out"
#setup error db
if ((Test-Path $out) -ne $true ){
@myclau
myclau / 0_kubectl related script
Last active June 2, 2023 02:13
kubectl related script
@myclau
myclau / remove image in registory v2
Created November 27, 2018 00:51
Remove image in registry v2
1. Login to the container
`docker exec -it registry sh`
2. Define variables matching your container and container version:
```export NAME="google/cadvisor"
export VERSION="v0.24.1"```
3. Move to the the registry directory:
`cd /var/lib/registry/docker/registry/v2`
@myclau
myclau / configmap
Created December 5, 2018 09:39
fluentd-graylog-k8s
<match fluent.**>
@type null
</match>
<source>
@type tail
@id in_tail_container_logs
limit_recently_modified 1s
path /var/log/containers/*.log
pos_file /var/rancher-fluentd/db/fluentd-containers.log.pos
function add-https-support(){
if ("TrustAllCertsPolicy" -as [type]) {
#"TrustAllCertsPolicy is already loaded"
}else{
#add https support
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
@myclau
myclau / azure_move_disk_toother_region.ps1
Last active June 24, 2019 01:34
Azure move disk to different region
#Provide the subscription Id where snapshot is created
$SubscriptionId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#Provide the name of your resource group where snapshot is created
$resourceGroupName="rgname"
#Provide the snapshot name
$SnapshotName = "snapshotname"
#Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.
#Know more about SAS here: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1
$sasExpiryDuration = "3600"
#Provide storage account name where you want to copy the snapshot.
@myclau
myclau / maven docker build image sample
Last active June 2, 2020 08:42
maven docker build image sample
#
# Build stage
#
FROM maven:3.6.0-jdk-11-slim AS build
COPY src /home/app/src
COPY pom.xml /home/app
RUN mvn -f /home/app/pom.xml clean package
#
# Package stage