Skip to content

Instantly share code, notes, and snippets.

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

Saiqul Haq saiqulhaq

🏠
Working from home
View GitHub Profile
@saiqulhaq
saiqulhaq / percona.sh
Created January 31, 2024 05:00
run percona monitoring and management
#!/usr/bin/env bash
#
# ###############################
# Script to run PMM 2.
# If docker is not installed, this script will try to install it as root user.
#
# Usage example:
# curl -fsSL https://raw.githubusercontent.com/percona/pmm/main/get-pmm.sh -o get-pmm2.sh; chmod +x get-pmm2.sh; ./get-pmm2.sh
#
#################################
@saiqulhaq
saiqulhaq / simplecov_rails_engine_minitest.rb
Last active January 6, 2024 07:19
Simplecov for Rails Engine with Minitest
# add this to your main library file
# lib/<engine_name>.rb
if ENV['RAILS_ENV'] == 'test'
require 'simplecov'
SimpleCov.start do
load_profile "test_frameworks"
add_filter %r{^/config/}
add_filter %r{^/db/}
@saiqulhaq
saiqulhaq / application_helper.rb
Created September 30, 2023 00:11
Rails active_link_to helper
module ApplicationHelper
def active_class(link_path)
current_path = request.path
# Special case for root path
return 'active' if current_path == '/' && link_path == '^/$'
return '' if current_path != '/' && link_path == '^/$'
# Use Regex to match the route or any conditions you need
current_path.match(Regexp.new(link_path)) ? 'active' : ''
@saiqulhaq
saiqulhaq / init.vim
Last active February 7, 2023 02:37
My Vim config
"set termguicolors
call plug#begin('~/.local/share/nvim/plugged')
Plug 'wakatime/vim-wakatime'
Plug 'hashivim/vim-terraform'
" Colorscheme
Plug('flazz/vim-colorschemes')
Plug('arcticicestudio/nord-vim')
@saiqulhaq
saiqulhaq / application_controller.rb
Created December 12, 2021 00:42
Ruby on Rails: include view files from gem/plugins
class ApplicationController < ActionController::Base
before_action :prepend_view_paths
def prepend_view_paths
prepend_view_path "#{Bundler.locked_gems.dependencies['your_gem_name'].source.path}/app/views/"
end
end
@saiqulhaq
saiqulhaq / compare.py
Created November 25, 2021 01:59 — forked from sanzoghenzo/compare.py
Compare Excel sheets with Pandas
"""
Compare two Excel sheets
Inspired by https://pbpython.com/excel-diff-pandas-update.html
For the documentation, download this file and type:
python compare.py --help
"""
import argparse
import pandas as pd
@saiqulhaq
saiqulhaq / toLocaleDateString.js
Created January 31, 2021 17:56
Date.toLocaleDateString.js
//Date.toLocaleDateString.js
(function(global) {
"use strict";
var dateFormatOverride = function(locale) {
var formatUS =
this.getMonth() + 1 + "/" + this.getDate() + "/" + this.getFullYear();
var formatTH =
this.getDate() +
"/" +
@saiqulhaq
saiqulhaq / Active Admin Customization Guide.md
Created June 15, 2019 06:17
Active Admin Customization Guide

I’ve been worked on a project that used ActiveAdmin for few times, So I think I need to write it down what I’ve learn.
However actually this guide is for my self, to be my quick reference when I need to use ActiveAdmin again later

Best Theme/Skin

There are few ActiveAdmin themes/skins out there, I was impressed by screenshot/showcase on their homepage, but the problem is coming when I need to make customization, it lacks of documentation, or even not written yet. So far ActiveMaterial theme by Viget is the best one for me, it is based on Google Material Theme, well written and have good documentation. It has few components like Bootstrap do, you can check it out on Google Material Theme components docs. Maybe you will find that some Google Material Theme components is not exist on ActiveMaterial, but give a try to check ActiveMaterial source code, I found that they already write the components, but it hasn’t been written yet.

Custom Form

It's been 4 years I use Ruby for server side, now I want to learn Golang, and this is my notes, based on Build web application with Golang book

Always work from $GOPATH

so change directory and create project directory there

cd $GOPATH

mkdir project
@saiqulhaq
saiqulhaq / Docker and Rails tips.md
Created June 15, 2019 06:11
Docker and Rails tips

2 months ago I got "Docker for Rails Developer" book. It's easy to follow step by step for beginner.

However I haven't try it for production purpose, because my projects are not ready yet to use Docker for production. There will many changes on assets, database, and caching system. So I use it for development environment only till now.

After few days learning this Docker thing, I found great gem to build Dockerfile and docker-compose.yml files rails. The gem is dockrails, it uses unison to sync your files.

If I could give a recommendation for you, I would recommend you to read "Docker for Rails Developer" book first, try to use it on new rails app, then use dockrails, so it will be easy when you struggle when setting up the env.

Following is my cheatsheet, maybe it would useful for you :)