Skip to content

Instantly share code, notes, and snippets.

View jeznag's full-sized avatar

Jeremy Nagel jeznag

View GitHub Profile
@jeznag
jeznag / gist:46dd43beb2a99bf4ba0beaa3579a31df
Last active September 17, 2016 07:46
unit tests in deluge
htmlpage Unit_Tests()
displayname = "Unit Tests for atan"
content
<%{
results = List:Map();
results.add({"function": "atan", "testCase": "50 radians", "actualResult": thisapp.trig.atan(50).round(2), "expectedResult": 1.55, "pass": thisapp.trig.atan(50).round(2) == 1.55});
results.add({"function": "atan", "testCase": "-50 radians", "actualResult": thisapp.trig.atan(-50).round(2), "expectedResult": -1.55, "pass": thisapp.trig.atan(-50).round(2) == -1.55});
results.add({"function": "atan", "testCase": "5 radians", "actualResult": thisapp.trig.atan(5).round(2), "expectedResult": 1.37, "pass": thisapp.trig.atan(5).round(2) == 1.37});
results.add({"function": "atan", "testCase": "0 radians", "actualResult": thisapp.trig.atan(0).round(2), "expectedResult": "0.00", "pass": thisapp.trig.atan(0).round(2) == 0.00});
%>
@jeznag
jeznag / numberOfDiscIntersections.js
Created October 3, 2016 02:18
Codility numberOfDiscIntersections javascript
function generateTestData(numArrayItems, minVal, maxVal, random){
return Array.from(Array(numArrayItems)).map((e,i) => {
if (random) {
return getRandomInt(minVal, maxVal);
}
return i + minVal;
});
}
function getRandomInt(min, max) {
@jeznag
jeznag / send_serial_data_to_adafruitio
Last active August 2, 2017 07:46
Send serial data to ada fruit IO
from Adafruit_IO import *
import sys, os, serial, threading
aio = Client('CLIENT_KEY')
def monitor():
ser = serial.Serial('/dev/tty.usbmodem1411', 9600)
while (1):
line = ser.readline()
if (line != ""):
@jeznag
jeznag / attachFilesToZohoCRM
Created September 10, 2017 02:00
Uploading files to Zoho CRM using Node.js
const request = require('request');
function attachFileToCRM(crmContactID) {
const urlForFileToAttach = 'http://example.com/blah.pdf';
const CRM_UPLOAD_FILES_URL = `https://crm.zoho.com/crm/private/json/Contacts/uploadFile?authtoken=${CRM_AUTH_TOKEN}&scope=crmapi&id=${crmContactID}`;
// You can use fs.createReadStream for local files
const readStream = request.get(urlForFileToAttach);
const formData = {
content: {
@jeznag
jeznag / gist:eb53f5742c6f9cebf3b6752b04fd25e2
Last active March 31, 2019 10:21
Automatically associating products to potential in Zoho CRM
AUTH_TOKEN = "CHANGEME";
quote_record = zoho.crm.getRecordById("Quotes", quote_id);
quote_products = quote_record.get("product").toJSONList();
related_products = zoho.crm.getRelatedRecords("Products", "Potentials", input.deal_id.toString());
row_index = 1;
xml_data = "<Products>";
for each product in quote_products {
product_map = product.toMap();
info product_map;
xml_data += "<row no=\"" + row_index + "\"><FL val=\"PRODUCTID\">" + product_map.get("Product Id") + "</FL></row>";
@jeznag
jeznag / gist:536c64ac94f762f8057633113b0a79ae
Created November 25, 2017 05:33
custom related list in Zoho CRM
string getProductsFromPurchaseorder(string purchase_order_id)
{
purchase_order_record = zoho.crm.getRecordById("PurchaseOrders",input.purchase_order_id.toLong());
line_items = purchase_order_record.get("product").toJSONList();
xml_for_related_list = "<record>";
idx = 0;
for each line_item in line_items
{
line_item_map=line_item.toMap();
xml_for_related_list=((xml_for_related_list + ("<row no='" + idx + "'><FL val='product name'>" + line_item_map.get("Product Name")) + "</FL><FL val='quantity'>") + line_item_map.get("Quantity")) + "</FL></row>";
@jeznag
jeznag / gist:e7d7b0a432b57e478e09bb59a60223cb
Created December 17, 2017 09:18
Zoho Creator html page example
htmlpage FilteredRides(ignore_lat, chosen_event, userLat, userLong, userDestLat, userDestLong, userOriginLocation, userOriginState, userDestState, userDestLocation, Travel_Mode)
content
<%{
if(input.userLong == null && input.userLat == null && input.ignore_lat != "yes")
{
%>
Could not find those locations in Google Maps. Try re-entering the addresses.
<%
}
else if((input.userLong != null && input.userLat != null) || input.ignore_lat == "yes")
^[\w]*[\s]*[\=]?[\s]*(\d+\.\d+)[\s]*[pcs]*
@jeznag
jeznag / gist:ce200a11f0a3fe3fa316c9d88bbbf30b
Created February 4, 2018 02:38
adding purchase orders
products_for_purchase_order = List:Map();
products_for_purchase_order.add({
"Product Id": product_for_purchase_order.get("PRODUCTID"),
"Quantity": item_data.get("quantity"),
"Product Name": product_for_purchase_order.get("Product Name"),
"Unit Price": product_for_purchase_order.get("Unit Price")
});
new_purchase_order = {
@jeznag
jeznag / gist:a755f5e56d6ee6d84bf629f42d7c68a6
Created March 3, 2018 06:02
downloading PDF from zoho creator
const fileStream = fs.createWriteStream(fileName);
const requestOptions = {
url: URL,
headers: {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36'
}
};
request(requestOptions).pipe(fileStream);