Skip to content

Instantly share code, notes, and snippets.

View utarn's full-sized avatar

Utharn Buranasaksee utarn

View GitHub Profile
@utarn
utarn / Program.cs
Created January 22, 2022 15:04
Dependency Injection for console app
namespace AppClient
{
static class Program
{
private static IConfiguration _configuration;
static async Task Main()
{
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
@utarn
utarn / docker-compose.yml
Last active June 17, 2024 21:33
Nextcloud docker-compose with Postgresql and Redis
# RUN THIS COMMAND BEFORE DOCKER UP
# postgresql user : 1001
# nextcloud user: 33
# mkdir -p app/config app/custom_apps app/data app/themes database/postgresql/data mail/domainkeys
# touch app/config/CAN_INSTALL
# chown 33 -R app/
# chown 1001 -R database/
version: '3'
@utarn
utarn / msmtprc
Created May 22, 2021 23:58
Smartmontool for centos 8 using Gmail amd msmtp
# path /etc/msmtprc
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
logfile /var/log/msmtp.log
# Gmail configuration
account gmail
host smtp.gmail.com
@utarn
utarn / install_docker_bash_completions.sh
Last active May 21, 2021 14:08 — forked from toschneck/install_docker_bash_completions.sh
Install Docker and Docker-Compose bash completion
#!/usr/bin/env bash
set -e
echo "install docker bash completion"
curl -L https://raw.githubusercontent.com/docker/cli/v$(docker version --format '{{.Server.Version}}' | sed 's/-.*//')/contrib/completion/bash/docker -o /etc/bash_completion.d/docker
echo "install docker-compose bash completion"
sudo curl \
-L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
-o /etc/bash_completion.d/docker-compose
@utarn
utarn / MakePowerShellRememberSSHPassphrase.md
Created May 20, 2021 06:26 — forked from danieldogeanu/MakePowerShellRememberSSHPassphrase.md
How to make Powershell remember the SSH key passphrase.

You should not use the Open SSH client that comes with Git for Windows. Instead, Windows 10 has its own implementation of Open SSH that is integrated with the system. To achieve this:

  1. Start the ssh-agent from Windows Services:
  • Type Services in the Start Menu or Win+R and then type services.msc to launch the Services window;
  • Find the OpenSSH Authentication Agent in the list and double click on it;
  • In the OpenSSH Authentication Agent Properties window that appears, choose Automatic from the Startup type: dropdown and click Start from Service status:. Make sure it now says Service status: Running.
  1. Configure Git to use the Windows 10 implementation of OpenSSH by issuing the following command in Powershell:
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
@utarn
utarn / ActiveRouteTagHelper.cs
Last active November 25, 2022 09:32 — forked from is-consulting/ActiveRouteTagHelper.cs
Asp.net Core 5.0 TagHelper for adding 'active' class to current active link. Compatible to lowercase routing, LowercaseUrls. Support C# Nullable
[HtmlTargetElement(Attributes = ControllersAttributeName)]
[HtmlTargetElement(Attributes = ActionsAttributeName)]
[HtmlTargetElement(Attributes = RouteAttributeName)]
[HtmlTargetElement(Attributes = ClassAttributeName)]
public class ActiveRouteTagHelper : TagHelper
{
private const string ActionsAttributeName = "asp-active-actions";
private const string ControllersAttributeName = "asp-active-controllers";
private const string ClassAttributeName = "asp-active-class";
private const string RouteAttributeName = "asp-active-route";
@utarn
utarn / localoelrepo.sh
Last active May 9, 2025 03:50
Add OEL 8 Local Repository
#!/bin/bash
if [ -z $1 ]; then
echo "Accepted parameter are either local or oracle"
elif [ $1 == "local" ]; then
cat << EOF > /etc/yum.repos.d/local-oracle-ol8.repo
[local_ol8_baseos_latest]
name=Oracle Linux 8 BaseOS Latest (\$basearch)
baseurl=http://oelrepo.zarimpun.com/OracleLinux/OL8/baseos/latest/\$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
@utarn
utarn / encryption note.txt
Last active December 25, 2020 00:34
Cryptography Note
Cryptography Lab
1. Symmetric encryption รหัสเดียวกันสำหรับเข้ารหัสและถอดรหัส
ข้อเด่น 1. เร็ว 2. คีย์ขนาดเล็กก็ปลอดภัย 256 บิต ก็ปลอดภัยมากๆ AES-256
ข้อเสีย 1. ส่งคีย์ข้ามอินเทอร์เน็ตยาก หรือถึงขั้นเป็นไปไม่ได้
2. Asymmetric encryption กุญแจคู่ ประกอบด้วยกุญแจส่วนตัวและกุญแจสาธารณะ
(Private key, Public key)
- ถ้าตัวใดตัวหนึ่งใช้เข้ารหัส ต้องใช้อีกตัวหนึ่งถอดรหัส
- ถ้า Public key หาย สามารถสร้างใหม่จาก Private key ได้
แต่ถ้า Private key หาย ไม่สามารถสร้างใหม่ได้
@utarn
utarn / encrypt_openssl.md
Created November 20, 2020 12:55 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@utarn
utarn / dump.csv
Created November 17, 2020 10:53
Sample Moodle accounts for testing
username firstname lastname email password
student1 Student 111 [email protected] 1!Qwerty
student2 Student 112 [email protected] 1!Qwerty
student3 Student 113 [email protected] 1!Qwerty
student4 Student 114 [email protected] 1!Qwerty
student5 Student 115 [email protected] 1!Qwerty
student6 Student 116 [email protected] 1!Qwerty
student7 Student 117 [email protected] 1!Qwerty
student8 Student 118 [email protected] 1!Qwerty
student9 Student 119 [email protected] 1!Qwerty