Skip to content

Instantly share code, notes, and snippets.

View python-consulting's full-sized avatar

python-consulting

View GitHub Profile
@python-consulting
python-consulting / Makefile-cookicutter
Created January 18, 2016 13:26
Use cookicutter python from makefile
app:
ifeq ("$(APP_NAME)", "")
@echo "A APP_NAME parameter is mandatory. Usage:"
@echo " make app APP_NAME=mainApp"
else
@cd $(PROJECT_ROOT) && echo "from cookiecutter.main import cookiecutter; cookiecutter('$(HERE)/ns-eggs/django-app', no_input=True, extra_context={'project_name': '{{cookiecutter.projectname|replace("-", "_")}}', 'app_name': '$(APP_NAME)',})" | $(PYTHON2)
ln -f -snv $(HERE)/parts/node/lib/node_modules $(HERE)/src_py/{{cookiecutter.projectname|replace("-", "_")}}/$(APP_NAME)/static/$(APP_NAME)/node_modules
endif
@python-consulting
python-consulting / views.py
Created December 16, 2015 14:43
Generic Django AppView
class AppView(View):
template_name = "conference/page.html"
def common(self, request):
# Rendue de la vue
return render(request, self.template_name, self._context)
def get_default_context(self):
default_context = {}
default_context.setdefault('version_package', conference.__version__)
@python-consulting
python-consulting / base.html
Created October 16, 2015 14:37
CSS optional if IE10+
<style type="text/css">
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* If IE10+ */
#typeahead-quicksearch{
line-height: 0.5em;
}
}
</style>
@python-consulting
python-consulting / main.py
Created September 22, 2015 15:34
begin (command line tool) template
"""
Do not forget to add the following in setup.py :
entry_points={
'console_scripts': [
'platform-ott = deploy_platform_ott.main:main.start',
],
},
"""
@python-consulting
python-consulting / main.py
Created September 22, 2015 14:19
python2 file header
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import, print_function
@python-consulting
python-consulting / index.rst
Created September 18, 2015 12:17
index.rst

<> Documentation

.. toctree::
   :maxdepth: 2

   <>
@python-consulting
python-consulting / test_unit.py
Last active September 19, 2016 12:24
Basic unittest template
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import, print_function
import unittest
class TestSuite(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
@python-consulting
python-consulting / gist:202aee17589d735d7772
Created March 11, 2015 10:35
Find and execute multi process
find . -regex '\./NAME' -type f -print0 | xargs -0 -n1 -P3 bzip2 --fast
import pymysql
pymysql.install_as_MySQLdb()
@python-consulting
python-consulting / gist:a26d2c929323210612f9
Created February 9, 2015 13:40
Python basic console app with log capabilities
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import logging
def set_log_level(log_level):
logging.basicConfig(format='%(levelname)s:%(message)s', level=log_level)
logging.info("Log level set to:%s" % log_level)