Skip to content

Instantly share code, notes, and snippets.

View Natgho's full-sized avatar
🐍
Dreaming

Sezer Bozkır Natgho

🐍
Dreaming
View GitHub Profile
@denji
denji / README.md
Last active May 7, 2025 07:38 — forked from Cubixmeister/README.md
Simple Sentry docker-compose.yml
  1. Download docker-compose.yml to dir named sentry
  2. Change SENTRY_SECRET_KEY to random 32 char string
  3. Run docker-compose up -d
  4. Run docker-compose exec sentry sentry upgrade to setup database and create admin user
  5. (Optional) Run docker-compose exec sentry pip install sentry-slack if you want slack plugin, it can be done later
  6. Run docker-compose restart sentry
  7. Sentry is now running on public port 9000
@bradmontgomery
bradmontgomery / example.py
Created August 16, 2016 16:57
Example of setting a choices value for django ArrayField
# Here's your list of choices that would be displayed in a drop-down
# element on the web. It needs to be a tuple, and we define this
# as a variable just for readability/convenience.
#
# This example has 3 choices, each of which consists of two parts:
# 1. the thing that get strored in your database
# 2. the thing that you see in a dropdown list
LABEL_CHOICES = (
('this gets stored in your database', 'This item is what you see in the drop-down'),
('django', 'Django'),
@dimasch
dimasch / redis-clear
Last active April 8, 2025 15:56
Clear a redis cache in Docker
docker exec -it container-name redis-cli FLUSHALL
@Kobold
Kobold / permissions.py
Created April 17, 2015 08:24
IsOwner - Custom django-rest-framework permission to only allow owners of an object to edit it.
from rest_framework import permissions
class IsOwner(permissions.BasePermission):
"""
Custom permission to only allow owners of an object to edit it.
"""
def has_permission(self, request, view):
return request.user and request.user.is_authenticated()
@benbacardi
benbacardi / gist:227f924ec1d9bedd242b
Last active January 18, 2025 22:00
Django reverse with a querystring
from django.utils.http import urlencode
def reverse_querystring(view, urlconf=None, args=None, kwargs=None, current_app=None, query_kwargs=None):
'''Custom reverse to handle query strings.
Usage:
reverse('app.views.my_view', kwargs={'pk': 123}, query_kwargs={'search': 'Bob'})
'''
base_url = reverse(view, urlconf=urlconf, args=args, kwargs=kwargs, current_app=current_app)
if query_kwargs:
return '{}?{}'.format(base_url, urlencode(query_kwargs))
@isccarrasco
isccarrasco / autopgsqlbackup.sh
Last active November 13, 2024 03:48 — forked from matthewlehner/autopgsqlbackup
Script to automate the postgresql database backups, this script can create backups for daily, weekly and monthly for an only database or all databases, also can create crontab task for backups using hours of backups.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@hirokazumiyaji
hirokazumiyaji / parallelmigrate.py
Last active May 18, 2023 09:24
django parallel migrate(per host)
# coding: utf-8
from __future__ import absolute_import, unicode_literals
from collections import defaultdict
import commands
from multiprocessing import Process
from django.conf import settings
from django.core.management.base import BaseCommand
@airsoull
airsoull / gist:6fbcb9461be35724b792
Last active July 30, 2024 09:31
Create temporary file and save model django
from django.core.files import File
from django.core.files.temp import NamedTemporaryFile
data = 'file'
file_temp = NamedTemporaryFile(delete=True, suffix='.py')
file_temp.write(data)
file_temp.flush()
Model.objects.create(file=File(file_temp))
@ungoldman
ungoldman / curl_post_json.md
Last active April 28, 2025 09:21
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@magopian
magopian / Makefile
Created November 15, 2012 11:02
Sample Makefile for Django (use with project templates)
.PHONY: all help translate test clean update compass collect rebuild
SETTINGS={{ project_name }}.settings
TEST_SETTINGS={{ project_name }}.test_settings
# target: all - Default target. Does nothing.
all:
@echo "Hello $(LOGNAME), nothing to do by default"
@echo "Try 'make help'"