Skip to content

Instantly share code, notes, and snippets.

@Alexx-G
Alexx-G / mountdb.sh
Created August 20, 2014 08:46
Mount/Umount mysql databases into ramdisk
#!/bin/sh
#stop mysql service
service mysql stop
#mount ramdisk
mkdir -p /tmp/db_ramdisk
mount -t tmpfs -o size=512M tmpfs /tmp/db_ramdisk
#create back-up
function searchBox() {
var box = $("#box");
if (box.length > 0) {
var elements = box.find("span");
var lvl = box.attr("class");
for(var i = 0; i < elements.length - 1; i++) {
if($(elements[i]).attr("style") != $(elements[i + 1]).attr("style")) {
$(elements[i]).click();
if(lvl == box.attr("class")) {
$(elements[i + 1]).click();
@Alexx-G
Alexx-G / postgreSQL_configuration.rst
Last active August 29, 2015 14:14
PostgreSQL configuration tutorial

Install PostgreSQL

  1. Install dependencies

    sudo apt-get install libpq-dev python-dev

    Note: If you're using python3, then use python-dev for python 3.

  2. Install PostgreSQL
@Alexx-G
Alexx-G / .gitignore
Created March 10, 2015 11:20
My gitignore file for django projects
# Python
*.py[cod]
venv/
__pycache__/
# Packages
dist/
lib/
lib64/
@Alexx-G
Alexx-G / settings.py
Last active August 29, 2015 14:19
Simple django logging configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s | %(asctime)s | %(name)s:%(funcName)s | %(process)d | %(thread)d | %(message)s'
},
'simple': {
'format': '%(levelname)s | %(name)s | %(message)s'
},
@Alexx-G
Alexx-G / django-startproject.sh
Last active August 29, 2015 14:23
A bash script for easier setup of the new django project.
#!/bin/bash
read -p "Project's folder (press Enter to install in current folder): " project_folder </dev/tty ;
read -p "Project name (required - letters, numbers underscore): " project_name </dev/tty ;
if [ -n "$project_folder" ]; then
mkdir $project_folder; cd $project_folder;
fi
@Alexx-G
Alexx-G / deployment.log
Created February 18, 2016 22:40
Heroku-like deployments on dedicated servers using git-deploy
emote: HEAD is now at e766da0 Move confirmed booking rendering in the same view.
remote: files changed: 5
remote: ============================================
remote: Exporting needed config variables (from .env)
remote: ============================================
remote: ============================================
remote: Installing nodejs dependencies
remote: ============================================
....
remote: [00:25:56] Using gulpfile /var/www/bakimli/gulpfile.js
@Alexx-G
Alexx-G / sitemaps.py
Last active February 26, 2016 11:38
Helper for autodiscovering of sitemaps modules based on Django's sitemap
# app/sitemaps.py
'''
Example of sitemaps module for a list of products.
For more info about sitemaps check out django docs
https://docs.djangoproject.com/en/stable/ref/contrib/sitemaps/
'''
from django.contrib.sitemaps import Sitemap
from .models import Product
@Alexx-G
Alexx-G / notification_clients.py
Created October 31, 2016 14:23
Interchangeable clients for sending notifications (in context of a Django app)
'''
This module contains interchangeable clients for sending notifications.
Use cases for those helpers:
- send notifications using a common interface;
- change the client in a transparent way (based on settings);
'''
from __future__ import unicode_literals
import logging
@Alexx-G
Alexx-G / middlewares.py
Last active October 12, 2018 09:30
A Django middleware for logging exceptions.
# -*- coding: utf8 -*-
from __future__ import unicode_literals
import logging
import sys
import traceback
LOGGER = logging.getLogger(__name__)