Skip to content

Instantly share code, notes, and snippets.

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

HM Tanbir hmtanbir

🏠
Working from home
  • BDMADE
  • Dhaka
View GitHub Profile
@hmtanbir
hmtanbir / MetaWrapper.jsx
Created April 19, 2023 05:17 — forked from Showrin/MetaWrapper.jsx
A component that implements basic SEO to any NextJS app
import Head from 'next/head';
import PropTypes from 'prop-types';
const MetaWrapper = (props) => {
const {
title,
description,
type,
imageUrl,
contentUrl,
@hmtanbir
hmtanbir / regenerate_credentials.md
Created November 22, 2022 02:37 — forked from db0sch/regenerate_credentials.md
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@hmtanbir
hmtanbir / rspec_model_testing_template.rb
Created December 30, 2021 07:31 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@hmtanbir
hmtanbir / script.sh
Created November 15, 2021 05:43 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@hmtanbir
hmtanbir / nginx_assets.md
Created November 1, 2021 16:34 — forked from vishaltelangre/nginx_assets.md
Serving Static Assets via Nginx

Concept

  • People talk about two servers: a web server (e.g. Nginx, Apache, etc.) and a app server (e.g. Language specific servers like Unicorn, Node.js, Tomcat, Http-Kit, etc.). There are exceptions where app servers not required at all (as web server itself provides preprocessors for handling), but let's not talk about now.
  • Web servers are really fast and supports lot of standard and commonly used MIME-type requests. Concept of serving a file is -- forming and sending a response of bytes of data and labeling it with requested MIME-type by a client (e.g. web browser).
  • Every response format (in layman's language, a file) is recognized by it's MIME-type, for e.g. a PNG image file has "image/png" MIME-type. JavaScript file has "text/javascript". HTML responses (or files) has "text/html". Plain text files have "text/plain".
  • Modern Browsers supports a lot of standard MIME-types. Images, videos, text files (XML, HTML, SVG, JS), and they better know how to visualize it. Browser also knows unrec
@hmtanbir
hmtanbir / windows10activation
Created December 9, 2020 14:56
Activate Windows 10 without Any Activator
1. Open CMD as Administrator
2. Paste the following commands into the Cmd: One by one, follow the order.
cscript slmgr.vbs /ipk "SERIAL NUMBER HERE"
Replace SERIAL NUMBER HER with any of these, according your Windows 10 installation type.
Home/Core TX9XD-98N7V-6WMQ6-BX7FG-H8Q99
Home/Core (Country Specific) PVMJN-6DFY6-9CCP6-7BKTT-D3WVR
Home/Core (Single Language) 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH
@hmtanbir
hmtanbir / install-node-js.sh
Created June 30, 2020 07:46 — forked from ankurk91/install-node-js.sh
Install node-js, npm and yarn on Ubuntu/Mac using nvm
#!/bin/sh
# Install node and npm via nvm - https://github.com/nvm-sh/nvm
# Run this script like - bash script-name.sh
# Define versions
INSTALL_NODE_VER=12
INSTALL_NVM_VER=0.35.3
@hmtanbir
hmtanbir / WebStorm_DataGrip
Created January 23, 2020 08:06 — forked from ShawNexT/WebStorm_DataGrip_IntelliJIdea
WebStorm & DataGrip renew license
cd ~/.WebStorm*
rm config/eval/WebStorm*evaluation.key
rm config/options/other.xml
cd ~/.java/.userPrefs/jetbrains
rm -rf webstorm
cd ~/.DataGrip*
rm config/eval/DataGrip*evaluation.key
rm config/options/other.xml
@hmtanbir
hmtanbir / puma.service
Created November 10, 2019 10:18
puma service
#Modify the path to the app directory and the user and group.
[Unit]
Description=Puma HTTP Server
After=network.target
# Uncomment for socket activation (see below)
# Requires=puma.socket
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
# Preferably configure a non-privileged user
@hmtanbir
hmtanbir / puma.rb
Created November 10, 2019 09:03
puma
# Change to match your CPU core count
workers 2
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Default to production