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 / gist:0ca74524b615a5d3d5c9e7cb0daad91e
Created May 27, 2020 08:08
Git list branch with sort and commit date
git for-each-ref --sort='-committerdate' --format='%(committerdate) -/- %(objectname:short) -/- %(refname:short) -/- %(subject)' refs/heads
@namnv609
namnv609 / dynamic_create_class_struct.rb
Created May 22, 2020 09:54
Dynamic create Struct class in Ruby (pure)
users_data = [{
"id": "7c5dae5552338874e5053f2534d2767a",
"email": "user@example.com",
"first_name": "John",
"last_name": "Appleseed",
"username": "cfuser12345",
"telephone": "+1 123-123-1234",
"country": "US",
"zipcode": "12345",
"created_on": "2014-01-01T05:20:00Z",
@namnv609
namnv609 / solar_lunar_converter.dart
Last active July 20, 2021 06:52
[Dart] Solar to Lunar Converter
class LunarDate {
final int year;
final int month;
final int day;
final int leapMonth;
final bool isLeapYear;
/// Constructs a [LunarDate] instance.
LunarDate(this.year, this.month, this.day, [this.isLeapYear = false, this.leapMonth = 0]);
@namnv609
namnv609 / ip_detail.dart
Created November 15, 2019 07:30
[Flutter][Simple app] hosts management GUI
import 'package:flutter/material.dart';
class IpDetail extends StatelessWidget {
final String ipAddr;
final List<String> ipDomains;
IpDetail(this.ipAddr, this.ipDomains);
@override
Widget build(BuildContext context) {
@namnv609
namnv609 / memory-log
Last active September 18, 2019 03:51
Log memory to CSV. View chart from log output at: https://codepen.io/namnv609/full/xxKybdW
#!/usr/bin/env bash
function get_time_format() {
time_str_formatted=$(TZ="Asia/Tokyo" date +"$1")
echo "$time_str_formatted"
}
function init_log_file() {
if [[ ! -f "$1" ]]; then
@namnv609
namnv609 / processes-check.sh
Created January 7, 2019 07:10
Processess check and alarm
#!/usr/bin/env bash
sidekiqProcessNumber=$(ps ax | grep -i [s]idekiq | wc -l)
pumaProcessNumber=$(ps ax | grep -i [p]uma | wc -l)
function pushWarningMessage()
{
serverIP=$(hostname -i)
jpTime=$(TZ=":Asia/Tokyo" date +"%Y/%m/%d %H:%M:%S")
vnTime=$(TZ=":Asia/Ho_Chi_Minh" date +"%Y/%m/%d %H:%M:%S")
@namnv609
namnv609 / bai-toan-ga-cho.pas
Created December 25, 2018 00:42
Bài toán gà chó bằng Pascal
program gaCho;
uses
crt;
var
chanGa, chanCho, soGa, soCho, i: integer;
begin
clrscr;
soCho := 0;
@namnv609
namnv609 / inexpress360-detail.rb
Created October 24, 2018 01:15
InExpress360.com crawler
# encoding: UTF-8
require "nokogiri"
require "open-uri"
require "terminal-table"
require "csv"
table_headings = ["STT", "Mã BC", "Tên Bưu cục", "BC cấp", "Địa chỉ", "Điện thoại"]
province = ARGV[0]
document = Nokogiri::HTML(open("https://inxpress360.com/ma-buu-dien-#{province}/"))
@namnv609
namnv609 / devvui-fb.rb
Created September 10, 2018 02:35
Simple crawler for DevVui fb fanpage
require "unirest"
require "nokogiri"
require "pry"
fb_url = "https://m.facebook.com/devvui/"
ua = "Mozilla/5.0 (Windows Phone 10.0; Android 6.0.1; WebView/3.0; NOKIA; Lumia 730 Dual SIM) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/55.100.7 Chrome/48.0.2564.82 Mobile Safari/537.36 Edge/14.14361"
html = Unirest.get fb_url, headers: {"User-Agent": ua}
doc = Nokogiri::HTML html.body
@namnv609
namnv609 / logrotate-puma-sidekiq
Created July 24, 2018 03:47
Logrotate configuration for Puma and Sidekiq
/path/to/log/folder/*.log {
su deployer deployer
daily
rotate 7
missingok
dateext
compress
notifempty
olddir /path/to/old/folder
sharedscripts