Skip to content

Instantly share code, notes, and snippets.

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

Mahfuzur Rahman mahfuz10

🏠
Working from home
View GitHub Profile
@mahfuz10
mahfuz10 / README.md
Created March 3, 2024 03:31 — forked from abelcallejo/README.md
Create bootable Linux USB using Mac

Creating bootable Linux USB using Mac

mac

CentOS, Ubuntu, Slackware, etc. Whatever Linux-based OS it is, you can create a bootable USB for it by using a Mac.

1. Prepare the .iso file

Download it, copy it, whatever it takes to prepare that Linux-based OS .iso file

2. Convert the .iso file into a .img.dmg

@mahfuz10
mahfuz10 / app-javascript-vue-chat-chat_element.vue
Created February 11, 2024 16:09
Some code from a chat example with React JS, in a Rails 7 application
<template>
<div class="chat-container"
:class="activeChat ? 'selected' : ''"
@click="$emit('chat:select', chat.id)" style="cursor: pointer">
<div class="chat-card-header">
<div class="chat-name">
{{ otherUser }}
</div>
<div class="chat-updated">
{{ chat.updated_at }}
@mahfuz10
mahfuz10 / marker_generator.dart
Created February 1, 2021 06:52 — forked from jbxbergdev/marker_icon_generator.dart
Creates a BitmapDescriptor from an IconData object to be used for google_maps_flutter map markers. Read the Medium article here: https://medium.com/@JBXBergDev/how-to-use-googlemap-markers-with-flutter-material-icons-38c4c975e928
import 'dart:math';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class MarkerGenerator {
final _markerSize;
double _circleStrokeWidth;
double _circleOffset;
@mahfuz10
mahfuz10 / git-pr
Last active October 3, 2020 04:07 — forked from jhnns/git-pr
Git custom command to quickly checkout pull-requests from different origins as described in https://help.github.com/articles/checking-out-pull-requests-locally. Place this file somewhere in your path and git will run it everytime you type `git pr ...`
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: git pr [clean] [<remote>] <id-or-url>"
echo ""
echo "Examples:"
echo "git pr 42 --> git fetch origin pull/42/head:pr/origin/42"
echo "git pr upstream 42 --> git fetch upstream pull/42/head:pr/upstream/42"
echo "git pr https://github.com/peerigon/phridge/pull/1 --> git fetch https://github.com/peerigon/phridge.git pull/1/head:pr/peerigon/phridge/1"
# echo "git pr clean --> Deletes all branches that match pr/*/* and pr/*/*/*"
@mahfuz10
mahfuz10 / APIDocExample.md
Created July 17, 2020 03:42 — forked from simonwep/APIDocExample.md
An API-Documentation example README

API Documentation Example

This API uses POST request to communicate and HTTP response codes to indenticate status and errors. All responses come in standard JSON. All requests must include a content-type of application/json and the body must be valid JSON.

Response Codes

Response Codes

200: Success
400: Bad request
401: Unauthorized
404: Cannot be found
@mahfuz10
mahfuz10 / psql-error-fix.md
Created May 23, 2020 06:43 — forked from AtulKsol/psql-error-fix.md
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

<script>
/*
MIT License
Copyright (c) 2017 Stripe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@mahfuz10
mahfuz10 / my_db.rake
Created January 7, 2020 08:03 — forked from jay16/my_db.rake
rails backup DB
#encoding: utf-8
require "fileutils"
namespace :my_db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
desc "usage - bundle exec rake my_db:backup RAILS_ENV=production MAX=15 DIR=db/db.bak"
task :backup => [:environment] do
# config base dir
datestamp = Time.now.strftime("%Y%m%d%H%M")
base_path = Rails.root
backup_folder = File.join(base_path, ENV["DIR"] || "backups")
FileUtils.mkdir_p(backup_folder) unless File.exist?(backup_folder)
@mahfuz10
mahfuz10 / backup.rake
Created January 7, 2020 08:02 — forked from rantoniuk/backup.rake
Rake task for backing up MySQL database in Rails projects
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
FileUtils.mkdir_p(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
@mahfuz10
mahfuz10 / letsencrypt-help-all
Created November 14, 2019 09:24 — forked from ebekker/letsencrypt-help-all
CLI help for letsencrypt client (letsencrypt-auto --help all)
usage:
letsencrypt [SUBCOMMAND] [options] [-d domain] [-d domain] ...
The Let's Encrypt agent can obtain and install HTTPS/TLS/SSL certificates. By
default, it will attempt to use a webserver both for obtaining and installing
the cert. Major SUBCOMMANDS are:
(default) run Obtain & install a cert in your current webserver
certonly Obtain cert, but do not install it (aka "auth")
install Install a previously obtained cert in a server