Skip to content

Instantly share code, notes, and snippets.

View README.rst

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

View patch_hide_admin_filter.diff
Index: django/contrib/admin/templates/admin/change_list.html
===================================================================
--- django/contrib/admin/templates/admin/change_list.html (revisión: 16133)
+++ django/contrib/admin/templates/admin/change_list.html (copia de trabajo)
@@ -27,6 +27,18 @@
(function($) {
$(document).ready(function($) {
$("tr input.action-select").actions();
+
+ $('#display-filter').click(function(event) {
@barseghyanartur
barseghyanartur / sortable_list.js
Created Jul 28, 2014
Using jQuery UI to add "drag and drop" reordering of items in the admin list view
View sortable_list.js
/*
* @author http://djangosnippets.org/users/chrsgrrtt/
* @link Taken from http://djangosnippets.org/snippets/2160/
* @updated by Artur Barseghyan (fixed)
*
* Original readme:
* Using jQuery UI to add "drag and drop" reordering of items in the admin list view. The model must have an "order"
* field to store the order value in.
*
* Add the following to your model admin
View sync_permissions.py
# http://djangosnippets.org/snippets/2398/
from django.core.management.base import BaseCommand
from django.db.models import get_models, get_app
from django.contrib.auth.management import create_permissions
class Command(BaseCommand):
args = '<app app ...>'
help = 'reloads permissions for specified apps, or all apps if no args are specified'
View gist:366ab52a19d92e06bc42
var detectBrowser = function(){
var ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE ' + (tem[1] || '');
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR\/(\d+)/);
if (tem != null) return 'Opera ' + tem[1];
View test_tld.py
"""
A test to see whether the tld module recognizes all the valid domains.
"""
import requests # http://docs.python-requests.org/en/latest/
import tld # https://pypi.python.org/pypi/tld
# Mozilla curated db of tlds. Used by tld module
tlds = requests.get("https://publicsuffix.org/list/effective_tld_names.dat")
valid_urls = 0
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Leaflet</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.3.1/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="http://matchingnotes.com/javascripts/leaflet-google.js"></script>
</head>
<body>
@barseghyanartur
barseghyanartur / gist:ec823de6311b51cd56cc
Created Feb 27, 2015
See SQL queries executed by Django in while doing things in Python shell
View gist:ec823de6311b51cd56cc
import logging
logger = logging.getLogger('django.db.backends')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
@barseghyanartur
barseghyanartur / gist:ea43b53dcc4afd71ef52
Last active Aug 29, 2015
virtualenvwrapper setup for Linux
View gist:ea43b53dcc4afd71ef52
sudo apt-get install python-setuptools
sudo easy_install virtualenv
sudo easy_install virtualenvwrapper
mkdir ~/.virtualenvs
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc
@barseghyanartur
barseghyanartur / gist:4aa87c34a30a364b9311
Last active Aug 29, 2015
A Django template filter to render the media files (JS and CSS) separately, instead of all together in just one place.
View gist:4aa87c34a30a364b9311
When you render the forms media, it puts all JS and CSS files in one place. Quite often you want to
have CSS to be rendered in the top of the page and JS at the bottom.
Below - a Django template filter to render the media files (JS and CSS) separately, instead of all
together in just one place.
In that way you can do the following in your template:
.. code-block:: html