Skip to content

Instantly share code, notes, and snippets.

View Barolina's full-sized avatar

꧁꧂Larisa Barolina

View GitHub Profile
@avidal
avidal / get_permissions.py
Created January 14, 2011 21:26
This snippet will get all permission objects for a specific model.
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from myapp.models import MyModel
content_type = ContentType.objects.get_for_model(MyModel)
permissions = Permission.objects.filter(content_type=content_type)
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@k0emt
k0emt / DarkMatterLogger.py
Created September 15, 2011 04:00
Demo code for RabbitMQ Publish/Subscribe (fanout) exchange with Python
import sys
import pika
# prerequisites are that you have RabbitMQ installed
# create a "darkmatter" named VirtualHost (VHOST)
# rabbitmqctl.bat add_vhost darkmatter
# create a user APP_USER with associated APP_PASS word
# rabbitmqctl add_user darkmatteradmin <password>
# give the APP_USER the necessary permissions
# rabbitmqctl set_permissions -p darkmatter darkmatteradmin ".*" ".*" ".*"
@evz
evz / LoadData.py
Created October 29, 2011 17:42
Making maps 101 - a few things I've picked up
#!/usr/bin/env python
# For this script to work you must set the Django settings file
# as an environment setting before importing LayerMapping
# Alternatively you can place
# export DJANGO_SETTINGS_MODULE=settings
# in your .bash_profile
# or paste this code into a $ manage.py shell
@pydanny
pydanny / api.group_permissions.py
Created December 31, 2011 20:30
django-rest-framework permissions by groups
""" User Django Rest Framework to check to see if an authenticated user
is in a particular group
Usage::
from api.group_permissions import GroupAPIGETPermission
class SearchProductView(View):
permissions = (IsAuthenticated, GroupAPIGETPermission,)
@CBoJI
CBoJI / gist:3798516
Created September 28, 2012 07:51
sphinx
http://sphinxsearch.com/downloads/ - скачать tar.gz
tar -xzf
cd
1)
./configure --without-mysql --with-pgsql --prefix=/usr/local/sphinx --with-pgsql-libs=/usr/lib/postgresql-9.1/ --with-pgsql-includes=/usr/include/postgresql-9.1/
2) make
3) make install
4) cd /usr/local/sphinx/etc/
создаем sphinx.conf
прописываем
@webgago
webgago / generate_keys.sh
Created October 7, 2012 19:10
Openssl with gost
openssl req -engine gost -newkey gost2001 -pkeyopt paramset:A -passout pass:11111111 -subj "/C=RU/ST=Moscow/L=Moscow/O=foo_bar/OU=foo_bar/CN=developer/emailAddress=vany.egorov@gmail.com" -keyout private.key.pem -out csr.csr
openssl x509 -engine gost -req -days 365 -in csr.csr -signkey private.key.pem -out crt.crt
openssl x509 -engine gost -inform pem -in crt.crt -pubkey -noout > public.key.pem
openssl dgst -engine gost -hex -sign private.key.pem message.xml
openssl smime -engine gost -sign -inkey private.key.pem -signer crt.crt -in message.xml
@kroger
kroger / gist:3856835
Created October 9, 2012 05:41
Example of Sphinx conf.py
# -*- coding: utf-8 -*-
import sys, os
sys.path.insert(0, os.path.abspath('extensions'))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo',
'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig',
'epub2', 'mobi', 'autoimage', 'code_example']
@kapkaev
kapkaev / gist:4619127
Created January 24, 2013 09:30
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@tmcw
tmcw / xyz_vs_tms.md
Last active April 3, 2024 06:18
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.