Skip to content

Instantly share code, notes, and snippets.

View utarn's full-sized avatar

Utharn Buranasaksee utarn

View GitHub Profile
@utarn
utarn / install.sh
Last active July 14, 2021 03:17
Script setup moodle docker
#!/bin/bash
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io firewalld
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --add-masquerade --permanent
#!/bin/bash
# Installation:
#
# 1. vim /etc/ssh/sshd_config
# PrintMotd no
#
# 2. vim /etc/pam.d/login
# # session optional pam_motd.so
#
@utarn
utarn / OAuth2Middleware.cs
Created August 25, 2020 23:00 — forked from yorek/OAuth2Middleware.cs
ASP.NET Core 2 Custom OAuth2 Authentication
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using Newtonsoft.Json.Linq;
@utarn
utarn / kubedump.sh
Created January 16, 2020 23:50 — forked from negz/kubedump.sh
Dump Kubernetes cluster resources as YAML
#!/usr/bin/env bash
set -e
CONTEXT="$1"
if [[ -z ${CONTEXT} ]]; then
echo "Usage: $0 KUBE-CONTEXT"
exit 1
fi
@utarn
utarn / gquickremove
Last active February 4, 2020 23:20
Google cloud script to manage container registry : Quick Remove
#!/bin/bash
#TODAY=$(date --date="yesterday" +%Y-%m-%d)
IMAGE=${1}
TODAY=$(gcloud container images list-tags asia.gcr.io/utarndocker/${IMAGE} | tail -n +2 | head -1 | cut -f3 -d" " | cut -f1 -d"-")
NORMALIZE_TODAY=${TODAY:0:4}-${TODAY:4:2}-${TODAY:6:2}
gremove $IMAGE $NORMALIZE_TODAY
@utarn
utarn / gremove.sh
Last active February 4, 2020 23:21
Bash script to manage Google container registry : Remove until date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@utarn
utarn / script.sh
Created November 20, 2019 11:21
Google cloud script to manage container registry
// .bashrc
alias glist='gcloud container images list --repository=asia.gcr.io/utarndocker'
gtag() {
gcloud container images list-tags asia.gcr.io/utarndocker/${1}
}
// gremove.sh
#!/bin/bash
@utarn
utarn / gcrgc.sh
Created November 20, 2019 11:10 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@utarn
utarn / dropall.sql
Created September 26, 2019 00:53
Drop all tables in SQL Server database file
EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'
EXEC sp_msforeachtable 'DROP TABLE ?'
@utarn
utarn / EnumExtension.cs
Created September 25, 2019 15:03
Enum extension to use Display(Name = "...")
public static class EnumExtension
{
public static string GetDisplayName(this Enum enumValue)
{
return enumValue.GetType()
.GetMember(enumValue.ToString())
.First()
.GetCustomAttribute<DisplayAttribute>()
.GetName();
}