Skip to content

Instantly share code, notes, and snippets.

View sharoonthomas's full-sized avatar

Sharoon Thomas sharoonthomas

View GitHub Profile
@sharoonthomas
sharoonthomas / print_barcode.py
Created April 29, 2016 14:33
Print barcodes on a zebra printer
import sys
# needs pip install zebra
from zebra import zebra
# Replace the string below.
# You can get valid names from zebra().getqueues()
printer_name = "Zebra_Technologies_ZTC_GC420d__EPL__2"
z = zebra(printer_name)
#!/usr/bin/env bash
# This script assumes that ImageMagick is installed and the convert command is accessible via the $PATH variable
# Ensure that one argument has been passed in.
if [ ! "$#" -eq 1 ]
then
echo -e "This script requires one argument.\\ne.g. iOS_icon_maker.sh app_icon.png"
exit 1
fi
@sharoonthomas
sharoonthomas / conftest.py
Created June 3, 2015 09:28
Example code using pytest with tryton tests
# -*- coding: utf-8 -*-
"""
tests/conftest.py
:copyright: (C) 2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import os
import time
import calendar
@sharoonthomas
sharoonthomas / migrate_ups_module.py
Last active August 29, 2015 14:17
For the sake of consistency, the module ups was renamed to shipping_ups. Tryton's migration API does not provide a straightforward way to rename modules as its an exceptional case. This file gives you the code you need to make the migration
# -*- coding: utf-8 -*-
import os
import psycopg2
# Connect to tryton database with database uri.
#
# Example: postgres://tryton:tryton@localhost/production
conn = psycopg2.connect(os.environ.get('TRYTOND_DATABASE_URI'))
conn.set_client_encoding('UTF8')
@sharoonthomas
sharoonthomas / gist:6e54065bafd57e6a4c51
Created January 31, 2015 12:41
Finding monday of a week
# Given a date find the monday and friday of the week
# This assumes that the week starts on sunday
import datetime
import calendar
from dateutil.relativedelta import relativedelta
def get_monday_in_week(date):
# Find the current week
current_week = date.isocalendar()[1]
delta = relativedelta(weeks=current_week-1, weekday=calendar.MONDAY)
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@sharoonthomas
sharoonthomas / gist:19ed690b46f6162cc300
Created January 23, 2015 20:35
Python Unicode Dict CSV Reader
# -*- coding: utf-8 -*-
"""
unicode_dict_reader
:copyright: (C) 2013-2015 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
import csv
class UnicodeDictReader(csv.DictReader):
def __init__(self, csvfile, *args, **kwargs):
diff --git a/emails/sale-confirmation-html.html b/emails/sale-confirmation-html.html
index 4a0ba5c..dfac4cb 100644
--- a/emails/sale-confirmation-html.html
+++ b/emails/sale-confirmation-html.html
@@ -8,6 +8,94 @@
{% endblock %}
</head>
<body>
+ {% block json_ld %}
+ <script type="application/ld+json">
@sharoonthomas
sharoonthomas / gist:0b425318b47b3dc999e1
Last active March 16, 2016 17:11
Tryton 3.4 config file (based on debian package)
# /etc/tryton/trytond.conf - Configuration file for Tryton Server (trytond)
#
# This file contains the most common settings for trytond (Defaults
# are commented).
# For more information install the tryton-server-doc package and read
# /usr/share/doc/tryton-server-doc/html/index.html
# and accordingly
# /usr/share/doc/tryton-server-doc/html/topics/configuration.html
[database]
@sharoonthomas
sharoonthomas / gist:e8930945a01098f2af84
Created December 29, 2014 06:36
Installing nereid CMS
sh-3.2$ cd /tmp
sh-3.2$ virtualenv test-nereid-cms-install
New python executable in test-nereid-cms-install/bin/python2.7
Also creating executable in test-nereid-cms-install/bin/python
Installing setuptools, pip...done.
sh-3.2$ cd test-nereid-cms-install/
sh-3.2$ source bin/activate
sh-3.2$ which pip
/private/tmp/test-nereid-cms-install/bin/pip
sh-3.2$ pip install trytond-nereid-cms