Skip to content

Instantly share code, notes, and snippets.

View kayode-adechinan's full-sized avatar

Kayode Adechinan kayode-adechinan

  • Dakar, Senegal
View GitHub Profile
pacman -S mariadb
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql //注意这个datadir,很重要,按照默认操作
systemctl enable mysqld
systemctl start mysqld
mysql_secure_installation

Disable HTML Form Input Autocomplete and Autofill

  1. Add autocomplete="off" onto <form> element;
  2. Add hidden <input> with autocomplete="false" as a first children element of the form.
<form autocomplete="off" method="post" action="">
    <input autocomplete="false" name="hidden" type="text" style="display:none;">
    ...
@kayode-adechinan
kayode-adechinan / settings.py
Created November 24, 2018 18:35 — forked from palewire/settings.py
My current default Django LOGGING configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',
@kayode-adechinan
kayode-adechinan / templatetags.py
Created November 19, 2018 17:34 — forked from benbacardi/templatetags.py
Django query_transform templatetag
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def query_transform(context, **kwargs):
'''
Returns the URL-encoded querystring for the current page,
updating the params with the key/value pairs passed to the tag.
@kayode-adechinan
kayode-adechinan / gist:90d5f68ed2f2a994c3955bbf4ec374a4
Created November 6, 2018 11:56 — forked from guillaumepiot/gist:5583149
DJANGO - Admin custom list filter
class CategoryListFilter(SimpleListFilter):
# USAGE
# In your admin class, pass trhe filter class as tuple for the list_filter attribute:
#
# list_filter = (CategoryListFilter,)
# Human-readable title which will be displayed in the
# right admin sidebar just above the filter options.
@kayode-adechinan
kayode-adechinan / clone-mysql-db.sh
Created November 3, 2018 16:41 — forked from christopher-hopper/clone-mysql-db.sh
Clone a MySQL database to a new database on the same server without using a dump file. This is much faster than using mysqldump.
#!/bin/bash
DBUSER="root";
DBPASS="";
DBHOST="localhost";
DB_OLD=mydatabase
DB_NEW=clone_mydatabase
DBCONN="--host=${DBHOST} --user=${DBUSER} --password=${DBPASS}";
@kayode-adechinan
kayode-adechinan / DjangoQuerySetToJsonResponse.py
Created September 25, 2018 17:42 — forked from leemac/DjangoQuerySetToJsonResponse.py
Example of returning a Django QuerySet as a JSON response (Django 1.7)
# Get the objects from the database
rawData = Launch.objects.all()
# Create array
json_res = []
# Iterate over results and add to array
for record in rawData:
json_obj = dict(name = record.name)
json_res.append(json_obj)
@kayode-adechinan
kayode-adechinan / Atom_export_settings.md
Created September 23, 2018 02:04 — forked from michalczukm/Atom_export_settings.md
Atom: Backup all settings

Export:

  1. Copy from ${user}/.atom:
  • config.cson
  • keymap.cson
  • snippets.cson
  • styles.less
  1. Save installed packages list apm list --installed --bare > packages.list
@kayode-adechinan
kayode-adechinan / postgres-cheatsheet.md
Created September 22, 2018 00:41 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
//Regular Expressions List
//Short Tutorial
\ // the escape character - used to find an instance of a metacharacter like a period, brackets, etc.
. // match any character except newline
x // match any instance of x
^x // match any character except x
[x] // match any instance of x in the bracketed range - [abxyz] will match any instance of a, b, x, y, or z
| // an OR operator - [x|y] will match an instance of x or y