Skip to content

Instantly share code, notes, and snippets.

View hien's full-sized avatar
🏠
Working from home

Hien Phan hien

🏠
Working from home
View GitHub Profile
@hien
hien / Validate-certificate.go
Last active October 11, 2022 04:18 — forked from hnakamur/main.go
Validate certificate key pair and hostname in Go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"log"
"golang.org/x/net/idna"
@hien
hien / gist:73f265edb3ee3b11c53554f6897f259b
Created May 4, 2022 06:13 — forked from ricjcosme/gist:c6f4c72644cc9bf0e63db7acc54bf6fb
Resizing a filesystem using qemu-img and fdisk

Occasionally we will deploy a virtual instance into our KVM infrastructure and realize after the fact that we need more local disk space available. This is the process we use to expand the disk image. This process assumes the following:

  • You're using legacy disk partitions. The process for LVM is similar and I will describe that in another post.
  • The partition you need to resize is the last partition on the disk.

This process will work with either a qcow2 or raw disk image. For

How to setup a practically free CDN

I've been using [Backblaze][bbz] for a while now as my online backup service. I have used a few others in the past. None were particularly satisfactory until Backblaze came along.

It was - still is - keenly priced at a flat $5 (£4) per month for unlimited backup (I've currently got just under half a terabyte backed-up). It has a fast, reliable client. The company itself is [transparent about their operations][trans] and [generous with their knowledge sharing][blog]. To me, this says they understand their customers well. I've never had reliability problems and everything about the outfit exudes a sense of simple, quick, solid quality. The service has even saved the day on a couple of occasions where I've lost files.

Safe to say, I'm a happy customer. If you're not already using Backblaze, [I highly recommend you do][recommend].

Taking on the big boys with B2

@hien
hien / sftp.yaml
Created December 6, 2021 08:42 — forked from jujhars13/sftp.yaml
kubernetes pod example for atmoz/sftp
apiVersion: v1
kind: Namespace
metadata:
name: sftp
---
kind: Service
apiVersion: v1
metadata:
#Magento Sheet:
#For search and replace in database file of magento
sed -i -e s'#DEFINER=`magento`@`%`#DEFINER=`cwdb`@`%`#'g file.sql
#Difference between Magento 1 and 2
env.php Magento 2
local.xml for Magento 1
"Magento 2.x"
#Checking for the IP's Performing DDOS attack.
netstat -ntu|awk '{print $5}'| cut -d: -f1 -s | sort| uniq -c| sort -nk1 -r
#**********Compression and Decompression**********#
#For compressing to tar.gz file
tar czvf create.tar.gz /directory/to/be/compressed/
#For Extracting tar.gz file in specific directory
tar -xzvf yourfile.tar.gz -C /extracting/directory
@hien
hien / MySQL_Sheet.sh
Created November 23, 2021 07:59 — forked from muhammad-owais-javed/MySQL_Sheet.sh
Useful MySQL queries and configurations
#MYSQL
#For login to mysql
mysql -h hostname -u dbusername -p dbname
#For taking dump of mysql
mysqldump -h hostname -u dbusername -p dbname > dbbackup.sql
#For taking dump without tablespaces
mysqldump -h hostname -u dbusername -p dbname --no-tablespaces > dbback.sql
#Wordpress Sheet
#For verifying Core wordpress files
wp core verify-checksums
#For restricting auto update of wordpress
define( 'WP_AUTO_UPDATE_CORE', false );
#For increasing memory limit
define('WP_MEMORY_LIMIT', '256M');
@hien
hien / OS-GreymonSheet.sh
Created November 23, 2021 07:57 — forked from muhammad-owais-javed/OS-GreymonSheet.sh
Scripts, Commands, Configurations, Package Deployments and Apache .htaccess rules particularly as per Cloudways stack
#OS-GreymonSheet
#For switching to Master user
for user in $(cat /etc/passwd | grep master | awk -F : '{print $1}'); do su $user; done
#For Finding application with corresponging domain name
grep -lr "domain.com" */conf/*
#For checking apache logs of every application in Cloudways
@hien
hien / wordpress.vcl
Created October 20, 2021 14:03 — forked from matthewjackowski/wordpress.vcl
Varnish 4 VCL configuration for WordPress. Also allows purging
# A heavily customized VCL to support WordPress
# Some items of note:
# Supports https
# Supports admin cookies for wp-admin
# Caches everything
# Support for custom error html page
vcl 4.0;
import directors;
import std;