Skip to content

Instantly share code, notes, and snippets.

View smartworld-dm's full-sized avatar
🏠
Working from home

Smart World smartworld-dm

🏠
Working from home
View GitHub Profile
@smartworld-dm
smartworld-dm / decorators.py
Created May 1, 2020 02:58 — forked from canokay/decorators.py
Django Custom View Decorators
from django.http import HttpResponseRedirect
from django.core.exceptions import PermissionDenied
from django.urls import reverse
from django.shortcuts import render
from django.shortcuts import redirect
def role_required(allowed_roles=[]):
def decorator(view_func):
def wrap(request, *args, **kwargs):
@smartworld-dm
smartworld-dm / pytz-time-zones.py
Created March 25, 2020 10:55 — forked from heyalexej/pytz-time-zones.py
list of pytz time zones
>>> import pytz
>>>
>>> for tz in pytz.all_timezones:
... print tz
...
...
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
@smartworld-dm
smartworld-dm / nginx.conf
Created October 15, 2019 09:55 — forked from baskaran-md/nginx.conf
NginX allow POST on static pages.
# ...
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
@smartworld-dm
smartworld-dm / commandline.txt
Created October 1, 2019 07:56 — forked from sandervm/commandline.txt
Generate Django secret key commandline
$ python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'
@smartworld-dm
smartworld-dm / middleware.py
Created June 29, 2019 19:20 — forked from rbtsolis/middleware.py
Django Access the Request or User Object Inside the Models and Signals
# 1) Create a middlewares/middlewares.py file and copy this:
import threading
class RequestMiddleware:
def __init__(self, get_response, thread_local=threading.local()):
self.get_response = get_response
self.thread_local = thread_local
# One-time configuration and initialization.
@smartworld-dm
smartworld-dm / disable-gpu-mac.md
Created December 16, 2018 04:00 — forked from marpontes/disable-gpu-mac.md
Pass --disable-gpu down to Electron apps on mac (Slack, Whatsapp, Trello, ...)

On my Macbook Pro (OS X El Capitan) I was having issues on Electron based apps. These apps had visual issues/glitches like blank screens, visual components showing only when hovering or transparent menus.

By opening with these comands, the problems disappeared.

open /Applications/Slack.app/ --args --disable-gpu
open /Applications/Trello.app/ --args --disable-gpu
open /Applications/Whatsapp.app/ --args --disable-gpu
@smartworld-dm
smartworld-dm / rm_mysql.md
Created December 10, 2018 23:03 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

@smartworld-dm
smartworld-dm / MySQL_macOS_Sierra.md
Created December 10, 2018 23:01 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :