Skip to content

Instantly share code, notes, and snippets.

@muhammadwafi
muhammadwafi / makefile
Created June 12, 2024 17:06
Makefile to run postgres and redis
#!/usr/bin/make
help:
@echo "make"
@echo " run-db"
@echo " Start postgresql and redis database"
@echo " stop-db"
@echo " Stop postgresql and redis database"
@echo " restart-db"
@echo " Restart postgresql and redis database"
@muhammadwafi
muhammadwafi / oauth2cookie.py
Created May 1, 2024 05:44
Oauth2 Password Bearer with Cookie - FastAPI
# originally from: https://github.com/nofoobar/JobBoard-Fastapi
from typing import Dict
from typing import Optional
from fastapi import HTTPException
from fastapi import Request
from fastapi import status
from fastapi.openapi.models import OAuthFlows as OAuthFlowsModel
from fastapi.security import OAuth2
@muhammadwafi
muhammadwafi / deploy-to-kinsta-sftp.yml
Created April 22, 2024 17:38
Github action to deploy code on Kinsta through SFTP
name: Deploy code to kinsta
on:
push:
branches:
- main
workflow_dispatch:
inputs:
sync:
description: 'File synchronization'
@muhammadwafi
muhammadwafi / deploy-to-ftp.yml
Last active April 22, 2024 17:39
Github action to deploy code on FTP server
name: Deploy code to FTP
on: push
jobs:
staging:
name: 🎉 Deploy on staging
if: github.ref_name == 'dev'
runs-on: ubuntu-latest
steps:
- name: Get latest staging code
uses: actions/checkout@v3
@muhammadwafi
muhammadwafi / paginateArray.js
Created November 30, 2021 13:02
Paginate js array
function paginate(array, page_size, page_number) {
// human-readable page numbers usually start with 1, so we reduce 1 in the first argument
return array.slice((page_number - 1) * page_size, page_number * page_size);
}
@muhammadwafi
muhammadwafi / mysql_alter_user.md
Created October 27, 2021 12:46
Laravel mysql access denied problem on WSL2
sudo service mysql stop

sudo mysql

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''

php artisan cache:clear

php artisan migrate
@muhammadwafi
muhammadwafi / meta-tags.md
Created September 29, 2021 04:11 — forked from whitingx/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@muhammadwafi
muhammadwafi / workbench.colorCustomizations.json
Created April 18, 2020 19:06 — forked from jacklorusso/workbench.colorCustomizations.json
A list of all Visual Studio Code customizable colors, grouped by UI region. Copy and paste into User Settings (comments are allowed) to tweak an existing theme or work on your own.
"workbench.colorCustomizations": {
// Contrast Colors - The contrast colors are typically only set for high contrast themes. If set, they add an additional border around items across the UI to increase the contrast.
"contrastActiveBorder": "",
"contrastBorder": "",
// Base Colors
"focusBorder": "",
"foreground": "",
"widget.shadow": "",
"selection.background": "",
"descriptionForeground": "",
@muhammadwafi
muhammadwafi / vscode-settings.json
Last active June 25, 2019 09:02
Preffered vscode settings
{
// ---- emmet config ----
"emmet.showExpandedAbbreviation": "never",
"emmet.triggerExpansionOnTab": true,
"emmet.showSuggestionsAsSnippets": true,
"editor.snippetSuggestions": "top",
"emmet.includeLanguages": {
"javascript": "javascriptreact",
"vue-html": "html",
"plaintext": "jade"