Skip to content

Instantly share code, notes, and snippets.

View iRaySpace's full-sized avatar
:octocat:
GitHubbing

Ivan Ray iRaySpace

:octocat:
GitHubbing
View GitHub Profile
@iRaySpace
iRaySpace / custom_script_report.html
Created April 28, 2017 07:17
Sample Frappe Report
<html>
<body>
<!-- Title Header -->
<h1 class="text-center">Sample Report HTML</h1>
<p class="text-center lead">{%= filters.month %} {%= filters.year %}</p>
<!-- Table -->
<div class="table-responsive">
<!-- Table -->
@iRaySpace
iRaySpace / file1.txt
Created January 24, 2019 08:05
Created via API
Demo
@iRaySpace
iRaySpace / zapier_code.py
Created February 18, 2019 08:03
An example for Code by Zapier in order to integrate with the Frappe
import json
# Item
item = {
'item_group': input['item_group'],
'stock_uom': input['uom'],
'item_code': input['item_code']
}
# Authorization header
@iRaySpace
iRaySpace / lambda_ec2_instances.py
Created June 19, 2020 07:18
AWS Lambda for EC2 Instances
import boto3
region = 'us-east-1'
instances = ['<instance>']
def start_instances(event, context):
ec2 = boto3.client('ec2', region_name=region)
ec2.start_instances(InstanceIds=instances)
print('Started Instances: ' + str(instances))
const x = 8;
const y = 8;
let arr = [];
for (let i = 0; i < x; i++) {
arr[i] = [];
let even = ' ';
let odd = '#';
if (i % 2 === 0) {
@iRaySpace
iRaySpace / extract_from_json_file.py
Created March 10, 2021 13:37
Commonly used in porting custom fields to another app
import json
# Commonly used in porting custom fields to another app
# bench execute <path>.extract_from_json_file --kwargs '{"filters": {"dt": "Branch"}}'
def extract_from_json_file(filters, in_file='input.json', out_file='output.json'):
if not filters:
raise Exception("Filters needed!")
# Input file
@iRaySpace
iRaySpace / concat_json_files.py
Last active March 10, 2021 14:07
Commonly used in porting custom fields to another app
# Commonly used in porting custom fields to another app
# bench execute <path>.concat_json_files --kwargs '{"in_file": "c1.json", "in2_file": "c2.json"}'
def concat_json_files(in_file, in2_file, out_file='output.json'):
if not in_file:
raise Exception("First file is needed!")
if not in2_file:
raise Exception("Second file is needed!")
# Input file
with open(in_file, "r") as file:
@iRaySpace
iRaySpace / install.py
Last active June 4, 2021 14:06
Fixed Python3.6 incompatibility for Linux x64 // as of commit frappe/bench@a7fec5c
#!/usr/bin/env python3
from __future__ import print_function
import os
import sys
import subprocess
import getpass
import json
import multiprocessing
@iRaySpace
iRaySpace / cookbook1.js
Created June 22, 2021 08:21
Code of the first cookbook
frappe.ui.form.on("Sales Invoice", {
custom_discount_percentage: function (frm) {
frm.doc.items.forEach((item) => {
frappe.model.set_value(
item.doctype,
item.name,
'discount_percentage',
frm.doc.custom_discount_percentage,
);
});
# under hooks.py
# ...
fixtures = [
{
"doctype": "Custom Field",
"filters": [
[
"name",
"in",
["Sales Invoice-custom_discount_percentage"],