Skip to content

Instantly share code, notes, and snippets.

View 0x0c72's full-sized avatar

Chris 0x0c72

View GitHub Profile
@0x0c72
0x0c72 / logical_and_behavior.py
Created July 19, 2021 03:42
Python logical and behavior
# Odd behavior from `and` operator where right side value of `and`
# is the resulting value after evaluation of the expression
value = 'value'
other_value = 'other value'
def true_func():
return True
def false_func():
@0x0c72
0x0c72 / Dockerfile
Created August 11, 2018 15:45
Docker ex
version: "3.6"
services:
app:
build:
context: .
args:
requirements: requirements/local.txt
environment:
- DJANGO_SETTINGS_MODULE=sasite.settings.local
- PYTHONDONTWRITEBYTECODE=1
@0x0c72
0x0c72 / Dockerfile
Created August 3, 2018 22:08
docker1
FROM python:3.6
LABEL maintainer cshenkan@shenkan-associates.com
ARG requirements=requirements/local.txt
ENV DJANGO_SETTINGS_MODULE=sasite.settings.local
WORKDIR /app
COPY manage.py /app/
COPY requirements/ /app/requirements/
@0x0c72
0x0c72 / docker-compose.yml
Last active August 3, 2018 02:25
docker-compose
version: "3.6"
services:
app:
build:
context: .
args:
requirements: requirements/development.txt
environment:
- DJANGO_SETTINGS_MODULE=sasite.settings.development
- PYTHONDONTWRITEBYTECODE=1
@0x0c72
0x0c72 / django-keywords-search.py
Created May 24, 2016 12:22
Search Comma Separated TextField in Django
def normalize_query(query_string,
findterms=re.compile(r'"([^"]+)"|(\S+)').findall,
normspace=re.compile(r'\s{2,}').sub):
''' Splits the query string in invidual keywords, getting rid of unecessary spaces
and grouping quoted words together.
Example:
>>> normalize_query(' some random words "with quotes " and spaces')
['some', 'random', 'words', 'with quotes', 'and', 'spaces']