Skip to content

Instantly share code, notes, and snippets.

View scmmishra's full-sized avatar
🎯
Focusing

Shivam Mishra scmmishra

🎯
Focusing
View GitHub Profile
@scmmishra
scmmishra / todo-cli.js
Last active July 28, 2021 12:19
today-cli
const sade = require("sade");
const os = require("os");
const { MultiSelect } = require("enquirer");
const fs = require("fs-extra");
const today = sade("today");
function getCurrentUser() {
return os.userInfo().username;
@scmmishra
scmmishra / server_script.py
Created December 9, 2020 07:35
These scripts will allow you to create read only web forms
if not doc.is_new() and frappe.session.user!="admin@example.com":
frappe.throw("You're not allowed to change this information after saving")
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import glob
import os
from frappe.utils import split_emails, get_backups_path, get_files_path
from frappe.utils.backups import BackupGenerator, new_backup
from PIL import Image
import os
def resize_images(path):
size = (600, 600)
for basepath, folders, files in os.walk(path):
for fname in files:
extn = fname.rsplit(".", 1)[1]
if extn in ("jpg", "jpeg", "png", "gif", "JPG"):
try:
@frappe.whitelist()
def send_invoice(doctype, docname, subject, message, recipient):
attachments = []
print_formats = ["PF1", "PF2", "PF3"]
for format_name in print_formats:
filename = docname + "" + format_name
pdf_attach = frappe.attach_print(doctype, docname, file_name=filename, print_format=format_name)
attachments.append(pdf_attach)
def append_hook(target, key, value):
if isinstance(value, dict):
# dict? make a list of values against each key
target.setdefault(key, {})
for inkey in value:
append_hook(target[key], inkey, value[inkey])
else:
# make a list
target.setdefault(key, [])
if not isinstance(value, list):
<div id="contributors-grid"></div>
<style>
#contributors-grid {
display: grid;
grid-template-columns: repeat(14, 1fr);
grid-column-gap: 5px;
grid-row-gap: 8px;
}
</style>
/*!
* Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
*/
/* FONT PATH
* -------------------------- */
@import url(/assets/frappe_theme/css/inter.css);
@font-face {
font-family: 'FontAwesome';
src: url("/assets/frappe/css/fonts/fontawesome/fontawesome-webfont.eot?v=4.7.0");
@scmmishra
scmmishra / captcha-webform.js
Last active January 25, 2024 02:27
Using reCaptcha to Validate Web Forms in ERPNext
// Create a reCaptcha v2 on https://www.google.com/recaptcha/admin/
// Copy the site key and paste it below
// Add a HTML field in the Lead DocType with fieldname "captcha_html_wrapper"
// Add the HTML field at the end of the fields child table
// Add the following to web form script
frappe.require("https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit&type=api.js")
let el = document.querySelector('[data-fieldname="captcha_html_wrapper"]');
window.captcha_failed = true;
Migrating erpnext-dev
Executing erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123 in erpnext-dev (_0acfbbe28584367f)
Traceback (most recent call last):
File "/Users/shivammishra/Projects/ERPNext/frappe-bench/apps/frappe/frappe/modules/utils.py", line 204, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File "/Users/shivammishra/Projects/ERPNext/frappe-bench/apps/frappe/frappe/__init__.py", line 842, in get_module
return importlib.import_module(modulename)
File "/Users/shivammishra/Projects/ERPNext/frappe-bench/env/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import