Skip to content

Instantly share code, notes, and snippets.

View KavenTheriault's full-sized avatar

Kaven Thériault KavenTheriault

View GitHub Profile
@KavenTheriault
KavenTheriault / clean_code.md
Last active August 21, 2018 07:24 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

What is Clean Code

  • elegant and efficient
  • does one thing well
  • can easily be read, and enhanced by a developer other than its original author
  • meaningful names
  • minimal dependencies
  • has unit and acceptance tests
  • clean code always looks like it was written by someone who cares
  • nothing obvious that you can do to make it better
  • no duplication
@KavenTheriault
KavenTheriault / Docker.md
Last active April 16, 2019 14:10
Docker cheat sheet

Build Image

Run at Dockerfile location or replace . with the the Dockerfile path

$ docker build -t image_name .

Images

$ docker images
$ docker rmi image_name
@KavenTheriault
KavenTheriault / MoveSQLFiles.md
Created January 5, 2018 20:26
Move SQL Server database files

Move SQL Server database files

1- Set the database offline

ALTER DATABASE DatabaseName SET OFFLINE WITH ROLLBACK IMMEDIATE;

2- Now you can move the files manualy

3- Set the new files location

@KavenTheriault
KavenTheriault / setup_ssh_keys_on_server.md
Last active June 26, 2018 15:34
SSH login without password using SSH keys

SSH login without password using SSH keys

Using ssh-copy-id command

ssh-copy-id -i ~/.ssh/my_key_rsa user@server_address

Manually

Enabling AuthorizedKeys

@KavenTheriault
KavenTheriault / simple_http_proxy.md
Last active February 24, 2026 13:46
Use SSH to Create an HTTP Proxy

Use SSH to Create an HTTP Proxy

All you need is virtual private server (VPS). Use the following command to open up the port 1080 on your local machine as a SOCKS proxy so all your HTTP traffic can be specified to go through the SSH tunnel and out remote_ssh_server on the other end.

$ ssh -D 1080 -f -C -q -N -p 22 user@server-ip

Use the SOCKS proxy in chrome

@KavenTheriault
KavenTheriault / a_plus_ssl_conf_nginx.md
Last active November 16, 2017 23:29
A+ SSL Test Nginx configuration

Generate your own key for DHE ciphers (ssl_dhparam)

$ sudo openssl dhparam -out /etc/ssl/dhparam.pem 2048

Trusted certificate (ssl_trusted_certificate)

Point to a trusted certificate chain file. This must contain the intermediate & root certificates (in that order from top to bottom). See exemple_full_chain.pem

Get the root and intermediate certificates from where you buyed the certificates. For me it was:

@KavenTheriault
KavenTheriault / redirect_http_to_https.md
Last active November 16, 2017 23:47
Nginx - Redirect http to https

Create file the following file /etc/nginx/site-available/redirect_http_to_https

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

Create symbolic link in the /etc/nginx/site-enabled/ folder

@KavenTheriault
KavenTheriault / extract_private_key_from_pfx.md
Last active November 15, 2017 20:26
How to extract certificate information (including private key) from pfx file

How to extract certificate information (including private key) from pfx file

Use openssl to extract private key. After executing the following line. you will need to enter the password used when the pfx file was created.

openssl pkcs12 -in file_name.pfx -out certificate.cer -nodes

When converting a PFX file to PEM format, OpenSSL will put all the certificates and the private key into a single file. You will need to open the file in a text editor and copy each certificate and private key (including the BEGIN/END statments) to its own individual text file and save them as certificate.cer, CACert.cer, and privateKey.key respectively.

@KavenTheriault
KavenTheriault / EntityCommand.md
Last active November 8, 2017 19:52
Entity command example

Install package with specific version

Install-Package EntityFramework -version 6.1.3

Run migration for specific connection string name

Update-Database -ConnectionStringName applicationDB2

Add migration with name "AddStateToUser" and compare database structure from specific connection string name

@KavenTheriault
KavenTheriault / nginx_reverse_proxy.md
Last active February 21, 2020 22:52
Configure Nginx Reverse Proxy as failover

Configure Nginx Reverse Proxy as failover

In this exemple of configuration, if the first server fail (proxy_connect_timeout) one time (max_fails), the second server will be used for 60s (fail_timeout).

The SSL certificate need to be configure on the ReverseProxy server AND the proxyied servers. You can use the same certificate and configurations on all servers.

To test the configuration you can change your host file to simulate the correct domain name.

Use the following tool to configure SSL with optimal configuration.