Skip to content

Instantly share code, notes, and snippets.

View mahbubzulkarnain's full-sized avatar
🏝️
I may be slow to respond.

Mahbub Zulkarnain mahbubzulkarnain

🏝️
I may be slow to respond.
View GitHub Profile
@mahbubzulkarnain
mahbubzulkarnain / rsa.go
Created April 24, 2024 07:56 — forked from sohamkamani/rsa.go
Example of RSA encryption, decryption, signing, and verification in Go
package main
import (
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"fmt"
)
@mahbubzulkarnain
mahbubzulkarnain / 55-bytes-of-css.md
Created October 2, 2022 22:15 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@mahbubzulkarnain
mahbubzulkarnain / main.go
Created July 5, 2022 02:22 — forked from fentas/main.go
♻ Endless running goroutine. Restart process if it fails. Manage multiple processes.
package main
import (
"log"
// replace right path
"[...]/utils"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
@mahbubzulkarnain
mahbubzulkarnain / check.go
Created May 18, 2022 11:31 — forked from mattes/check.go
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@mahbubzulkarnain
mahbubzulkarnain / postgres_fdw.sql
Created March 25, 2022 03:34 — forked from sathed/postgres_fdw.sql
postgres_fdw example
/***** "Remote" server first *****/
-- Note: Unless the object you are trying to gain access to is in the same DATABASE, it's a remote datebase. Even if it's
-- on the same node!
-- 1. create the role and assign it a password. Note: CREATE USER is an alias for CREATE ROLE. Either one is fine
CREATE ROLE new_user WITH PASSWORD 'somepassword';
-- 2. Grant the required permissions. This grants select, insert, update, and delete on all tables in the public schema.
-- I also gave execute to all functions in the public schema as well.
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO new_user;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO new_user;
@mahbubzulkarnain
mahbubzulkarnain / slugify.php
Created September 22, 2020 20:41
Generate slug from string
if ( ! function_exists("slugify")) {
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
@mahbubzulkarnain
mahbubzulkarnain / mime2ext.php
Created September 22, 2020 20:37
To take extension from mime type
if ( ! function_exists("mime2ext")) {
function mime2ext($mime)
{
$all_mimes = [
'png' => [0 => 'image/png', 1 => 'image/x-png'],
'bmp' => [
0 => 'image/bmp',
1 => 'image/x-bmp',
2 => 'image/x-bitmap',
3 => 'image/x-xbitmap',
#!/bin/sh
# default commands for osx to make it nicer to work with
##########################
# General UI?UX settings #
##########################
# Set hostname (hex of MVB9APPS)
sudo scutil --set ComputerName "0x4d56423941505053"
sudo scutil --set HostName "0x4d56423941505053"