Skip to content

Instantly share code, notes, and snippets.

View namnv609's full-sized avatar
🥰
Preparing for something new

NamNV609 namnv609

🥰
Preparing for something new
View GitHub Profile
@namnv609
namnv609 / action_controller_review.md
Created July 13, 2023 08:54 — forked from jamesyang124/action_controller_review.md
Notes for action controller overview from Rails official site. rails 4.2
@namnv609
namnv609 / gen-pr-desc
Created November 10, 2022 02:57
Generate PR desc for my project
#!/usr/bin/env ruby
require "optparse"
require "fileutils"
options = {}
current_work_dir = ::File.expand_path(::File.dirname(__FILE__))
current_date_time = Time.now.strftime("%Y%m%d-%H%M")
OptionParser.new do |opts|
@namnv609
namnv609 / ec2ssh_update.py
Last active January 19, 2022 07:41
Simple script to update SSH config file from AutoScaling groups
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Update SSH config file from AutoScaling groups
Author: NamNV609
Copyright: 2022, NamNV609
Homepage: https://github.com/namnv609
"""
@namnv609
namnv609 / README.md
Last active November 20, 2023 10:22
[MacOS] Convert Movie to MP4 using FFMPEG

[MacOS] Convert Movie to MP4 using FFMPEG

For terminal

Install

chmod +x <path/to/movie2mp4.sh>

ln -s <path/to/movie2mp4.sh> /usr/local/bin/movie2mp4

Usage

@namnv609
namnv609 / README.md
Created July 20, 2021 06:32
Simple hosts file parser

Simple hosts file parser

HostsParser.new(os: :mac).parse

Result:

{"127.0.0.1"=&gt;
@namnv609
namnv609 / README.md
Last active June 3, 2022 08:23
[Bash] Git bulk rebase

Git bulk rebase

Use case

When you have multiple branches need to rebase with same a branch. You need to switch to each branch and rebase it. This script help you to automate switch and rebase with each branch with main branch (auto get or you can passing it into first argument)

Usage

./git-bulk-rebase.sh <main branch>
@namnv609
namnv609 / nginx.conf
Created August 3, 2020 09:33 — forked from weapp/nginx.conf
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
@namnv609
namnv609 / csp-report-log.js
Created August 3, 2020 09:20
Write Content-Security-Policy header log to Google Spreadsheet
/**
* Name: CSP Report Log
* Description: Write Content-Security-Policy header log to Google Spreadsheet
* Author: NamNV609 <[email protected]>
* Homepage: https://github.com/namnv609
* License: MIT
*/
const SHEET_NAME = "<Sheet Name>";
const SCRIPT_PROP = PropertiesService.getScriptProperties();
@namnv609
namnv609 / string-padding.js
Created July 10, 2020 08:55
Simple string padding for JS (like Ruby ljust and rjust)
String.prototype.rJust = function(padLen, padStr) {
return (new Array(padLen).join(padStr) + this.valueOf()).slice(-padLen);
};
String.prototype.lJust = function(padLen, padStr) {
return (this.valueOf() + new Array(padLen).join(padStr)).substring(0, padLen);
};
/**
* > "6969".lJust(10, "0")
@namnv609
namnv609 / decrypt_session_cookie.rb
Created June 1, 2020 04:25
Decrypt session cookie content in Rails