Skip to content

Instantly share code, notes, and snippets.

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

Manjurul Hoque Rumi manjurulhoque

🏠
Working from home
View GitHub Profile
@manjurulhoque
manjurulhoque / middlewares.py
Created October 19, 2022 18:08
Create custom middleware to save prometheus data
from django.utils.deprecation import MiddlewareMixin
from django.utils.timezone import now
from jobsapp.metrics import requests_total, last_user_activity_time
class CustomMiddleware(MiddlewareMixin):
def __init__(self, get_response):
self.get_response = get_response
ssh into the server and goto the directory
then create a folder using mkdir, cd into that folder. create virtualenv and activate that env
clone project using git and goto the project directory. install dependencies using pip install -r requirements.txt.
create service file sudo nano /etc/systemd/system/<name>.service and configure like below:
[Unit]
Description=gunicorn daemon for listen music project
@manjurulhoque
manjurulhoque / gist:7abf84d9963f2d119ea1a03f7a194804
Created January 9, 2021 08:05
Github follow all people in a page
let forms = document.querySelectorAll('[aria-label="Follow this person"]');
for(var i = 0; i < forms.length; i++) {
forms[i].click();
}
@manjurulhoque
manjurulhoque / History|-109b1fad|entries.json
Last active October 2, 2022 13:35
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///home/rumi/Desktop/projects/nodejs/webrtc/frontend/src/components/shared/Card/Card.module.css","entries":[{"id":"lC2W.css","timestamp":1664637792376}]}
@manjurulhoque
manjurulhoque / django-send-sms-twilio
Created June 20, 2019 06:29
Send SMS Message using Twilio - Django
from twilio.rest import Client
from django.conf import settings
from django.http import HttpResponse
def send_sms(request):
message = 'Add Your Message Here'
from = 'Your Twilio Number Here'
to = 'Reciever Phone Number'
client = Client(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_AUTH_TOKEN)
response = client.messages.create(body=message, to=to, from_=from_)
@manjurulhoque
manjurulhoque / Dockerfile
Created June 16, 2019 17:30 — forked from amitavroy/Dockerfile
Docker setup with Laravel
FROM php:7.2.10-apache-stretch
RUN apt-get update -yqq && \
apt-get install -y apt-utils zip unzip && \
apt-get install -y nano && \
apt-get install -y libzip-dev libpq-dev && \
a2enmod rewrite && \
docker-php-ext-install pdo_pgsql && \
docker-php-ext-install pgsql && \
docker-php-ext-configure zip --with-libzip && \
@manjurulhoque
manjurulhoque / docker-help.md
Created June 12, 2019 17:11 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@manjurulhoque
manjurulhoque / Deployment Guide for Ubuntu Server from Scratch with Laravel.md
Last active March 13, 2020 04:01
Deployment Guide for Ubuntu Server from Scratch with Laravel

Setting Up Laravel in Ubuntu / DigitalOcean

Getting Started

  • Create droplet with Ubuntu 18.10
  • ssh root@[DROPLET IP ADDRESS]
  • Get password from your email
  • Change password on first login
  • adduser laravel
  • Enter password and other information
@manjurulhoque
manjurulhoque / custom_exception.py
Created April 9, 2019 12:22 — forked from harunurkst/custom_exception.py
Custom exception handler for Django rest framework
def format_code(code_name):
"""Format django error code to Circle Error code"""
if code_name == 'blank':
return "BLANK_FIELD"
elif code_name == 'invalid':
return "INVALID_DATA"
elif code_name == 'required':
return "KEY_ERROR"
else:
from django.urls import path
from . import views
app_name = 'accounts'
urlpatterns = [
path('login', views.Login.as_view(), name='login'),
path('register', views.Register.as_view(), name='register'),
path('logout', views.LogoutView.as_view(), name='logout'),