Skip to content

Instantly share code, notes, and snippets.

View daubac402's full-sized avatar
πŸ‡»πŸ‡³
πŸŽ„

NguyenTheAnh daubac402

πŸ‡»πŸ‡³
πŸŽ„
View GitHub Profile
@daubac402
daubac402 / minification.md
Created April 9, 2021 08:42 — forked from gaearon/minification.md
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@daubac402
daubac402 / self-signed-certificate-with-custom-ca.md
Last active April 7, 2021 05:45 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

1. Create Root CA (Done once)

1.1. Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@daubac402
daubac402 / Add and new user for SSH
Created March 25, 2021 05:37
Add and new user for SSH
$ sudo useradd new_user
$ sudo passwd new_user
# Create new_user key pair, then add public key into that user's authorized_keys
$ sudo mkdir /home/new_user/.ssh/
$ sudo vim /home/new_user/.ssh/authorized_keys
# And permission
$ sudo chown new_user:new_user -R /home/new_user/
$ sudo chmod 700 /home/new_user/.ssh/
@daubac402
daubac402 / Add an user to sudoers list (no password required)
Created January 19, 2021 01:37
Add an user to sudoers list (no password required)
# Let’s say you want to allow the user to run sudo commands without being asked for a password
# Login as root
$ su
# Edit /etc/sudoers
$ visudo
# Add this line to the last, with username is the username that you want to add to sudoers, then save (:wq)
username ALL=(ALL) NOPASSWD:ALL
@daubac402
daubac402 / Bypass outbound port firewall USING SSH Tunneling + tsocks
Last active March 11, 2022 06:15
Bypass outbound port firewall USING SSH Tunneling + tsocks (Tested on Windows 10 + WSL)
# You will connect to the internet through a 3rd server (using SSH Tunneling)
# And of course, this 3rd server needs to connect to the Internet freedomly!
sudo apt-get install tsocks
sudo vim /etc/tsocks.conf
Change near the end of file to:
server = 127.0.0.1
server_port = 1080
@daubac402
daubac402 / Check Windows Security Event Log
Created December 2, 2020 04:59
Check Windows Security Event Log
1. Open EventViewer
2. Check these logs:
- Windows Log > Application
- Windows Log > Security (Check EventID 4624, 4625 for Success and Failed Login)
- Windows Log > System
- Application Service Log > Microsoft > Windows > TaskScheduler > Operational
- Microsoft > Windows > TerminalServices-ClientActiveXCore > ...RPDClient/Operational
- Microsoft > Windows > TerminalServices-LocalSessionManager > Operational
- Microsoft > Windows > TerminalServices-RemoteConnectionManager > Operational
@daubac402
daubac402 / Prepare to OPTIMIZE MySQL tables
Created November 12, 2020 08:39
Prepare to OPTIMIZE MySQL tables
1. Check current defrag status:
SQL> select table_name,round(data_length/1024/1024) as data_length_mb, round(data_free/1024/1024) as data_free_mb from information_schema.tables order by data_free_mb;
2. Optimize one table or multi:
SQL> OPTIMIZE TABLE your_table_name;
SQL> OPTIMIZE TABLE your_table_name1, your_table_name2, your_table_name3;
(or)
Optimize all of your tables in "your_database":
(from bash, not in mysql client bash)
@daubac402
daubac402 / Oracle DDL to C# Data modal.php
Last active May 1, 2020 02:31
Oracle DDL to C# Data modal
<?php
$str = 'ID VARCHAR2(5) not null
NAME VARCHAR2(50),
ADDRESS VARCHAR2(200),
TEL VARCHAR2(30),
FAX VARCHAR2(30)';
function db_column($field) {
@daubac402
daubac402 / Guide for converting books to Amazon Kindle using Calibre (avoiding font error conversion)
Last active February 11, 2022 12:19
Guide for converting books to Amazon Kindle using Calibre (avoiding font error conversion)
a) (This needs to be done only once at first)
Configure Calibre to remove 'font-family' style element during conversion:
In Calubre,
--> "Preferences"
--> "Convertion > Common Options"
--> "Look & Feel"
--> "Styling" tab
--> in "Filter Style Information"
--> check "Fonts" checkbox
@daubac402
daubac402 / Enable SSI to laradock apache2
Last active June 23, 2021 02:25
Enable SSI (Server Side Includes) to laradock apache2
1. vim /your_laradock_location/apache2/Dockerfile, add this before "COPY vhost.conf /etc/apache2/sites-enabled/vhost.conf" and ENTRYPOINT line:
RUN a2enmod include
RUN service httpd restart
2. Rebuild apache2 image (at your_laradock_location)
docker-compose build --no-cache apache2
3. docker-compose up -d apache2 mysql phpmyadmin workspace