This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import datetime as dt | |
from hypothesis import assume, given, example | |
from hypothesis.strategies import text, integers, floats, dates, composite, shared | |
# also discuss: from_regex, random and shared strategies: http://hypothesis.readthedocs.io/en/latest/data.html | |
class TestTransaction(unittest.TestCase): | |
@composite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Manual Install: | |
git clone https://github.com/frappe/bench bench-repo | |
pip install --user -e bench-repo | |
#delete existing site databases if reinstalling: | |
sudo mysql -u root - p # then it expects root MySQL password | |
show databases; | |
drop database alskjdfhalsdfhasldfj; | |
# name the bench based on client or workflow desired eg "Evaqua" or frappe-bench-backup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors | |
# For license information, please see license.txt | |
from __future__ import unicode_literals | |
import frappe | |
from frappe import _, scrub | |
from frappe.utils import flt, nowdate | |
from frappe.model.document import Document |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# datetime | |
# dateutil | |
# parser is awesome: https://dateutil.readthedocs.io/en/stable/parser.html, built into pendulum and Maya | |
# datetime | |
# arrow vs pendulum: https://www.reddit.com/r/Python/comments/595tcd/please_stop_using_arrow_for_your_datetime/ | |
# timestring -> similar to ctparse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install tesseract per instructions for your os | |
# ubuntu: sudo apt-get install tesseract-ocr | |
# sudo pip install pytesseract | |
# sudo pip install python-Levenshtein | |
# sudo pip install fuzzywuzzy | |
# load image(s) in working directory | |
import re | |
import pytesseract | |
import pillow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install git | |
sudo apt-get install python-minimal | |
sudo apt-get install software-properties-common | |
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 | |
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.3/ubuntu xenial main' | |
sudo apt-get update | |
sudo apt-get install mariadb-server-10.3 | |
sudo apt-get install libmysqlclient-dev | |
sudo apt install python-pip | |
# do not upgrade pip; breaks in pip bench install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// USB Event Detection | |
const usbDetect = require('usb-detection'); | |
// USB HID library used to interface with USB devices | |
const HID = require('node-hid'); | |
class Scanner { | |
constructor(config, socket) { | |
this.socket = socket; | |
this.device = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%} | |
{% if letter_head and not no_letterhead %} | |
<div class="letter-head">{{ letter_head }}</div> | |
{% endif %} | |
{%- if doc.meta.is_submittable and doc.docstatus==0-%} | |
<div class="alert alert-info text-center"> | |
<h4 style="margin: 0px;">{{ _("DRAFT") }}</h4></div> | |
{%- endif -%} | |
{%- if doc.meta.is_submittable and doc.docstatus==2-%} | |
<div class="alert alert-danger text-center"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from base64 import b64encode | |
import json | |
def push_po(doc, method): | |
# additional business logic or other validations | |
# prune document fields and turn into json | |
payload = json.loads({"docfield": doc}) | |
api_key, api_secret = frappe.get_value("User", frappe.session.user, ["api_key", "api_secret"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Overriding Whitelisted Methods (in my_app/hooks.py) | |
# ------------------------------ | |
override_whitelisted_methods = { | |
"frappe.model.workflow.apply_workflow": "my_app.workflows.apply_workflow" | |
} | |
# in my_app/workflows.py | |
import frappe | |
from frappe.model.workflow import apply_workflow as model_apply_workflow |
OlderNewer