Skip to content

Instantly share code, notes, and snippets.

View NickDeckerDevs's full-sized avatar

nicholas decker NickDeckerDevs

View GitHub Profile
@NickDeckerDevs
NickDeckerDevs / chatgpt 4o.js
Created February 28, 2025 18:36
gpt / claude model comparison for a specific query
//Here’s a function that takes the GraphQL response and calculates the required totals for the company and affiliates:
function processPipelineData(data) {
if (!data || !data.CRM || !data.CRM.contact || !data.CRM.contact.associations) {
return { companyPipeline: {}, affiliatePipeline: {} };
}
const companyData = data.CRM.contact.associations.company?.items[0];
if (!companyData || !companyData.associations) {
import requests
import pandas as pd
import time
def fetch_players(gender):
base_url = "https://drop-api.ea.com/rating/ea-sports-fc?locale=en&limit=100&gender="
offset = 0
all_players = []
while True:
@NickDeckerDevs
NickDeckerDevs / fixLanguage.js
Last active February 14, 2025 14:53
HubSpot Community Script to force langage to your preferred language, has options for language, number of years before expiration, and a debug mode if you want to log stuff to the console. When someone sends you a link and it is forced language from a url param (or you happen to click on one) this will remove that from the url, and automatically…
// This can be added as a boost in Arc Browsers for the community by adding this JS
// Non Arc Users can use a chrome extension TamperMonkey
// I have not ussed this, I only see it show up on stack overflow as solution
// https://chromewebstore.google.com/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo
// this could also be turned into a chrome extension, but my account is not verfied and I don't know how
// to get it to work, so lol if you find this useful and you know how to get a extension account
// figured out, let me know!
(function() {
// set your language code here
I'm going to respond here and talk through some of the issues that make this difficult to do in HubSpot
so, to get today's date we use `{{ local_dt }}` -- and we could just covert that to a timestamp using `{{ local_dt|unixtimestamp }}` and that would give me a unixtimestamp that I can use, but we really need "midnight" because we need the start of the today if we want to know if anything was updated today.
In the code below I'm going to use the `|pprint` filter, which will show us what "types" these variables are as we convert them
```
<p>local_dt|pprint: {{ local_dt|pprint }}</p>
{# output: local_dt|pprint: (PyishDate: 2024-12-19 12:24:03) #}
<p>local_dt|format_date('M/d/yy'): {{ local_dt|format_date('M/d/yy')|pprint }}</p>
{# output: local_dt|format_date('M/d/yy'): (String: 12/19/24) #}
<p>local_dt|format_date('M/d/yy')|strtodate('M/d/yy'): {{ local_dt|format_date('M/d/yy')|strtodate('M/d/yy')|pprint }}</p>
{# output: local_dt|format_date('M/d/yy')|strtodate('M/d/yy'): (PyishDate: 2024-12-19 00:00:00) #}
@NickDeckerDevs
NickDeckerDevs / gist:ce4896cce76fb9e9d473083d68491481
Last active December 19, 2024 18:07
hubspot - crm objects getting products and converting dates to compare for anything updated from midnight until now
{% set products = crm_objects("product", "limit=100") %}
{% set midnight_today = local_dt|format_date('M/d/yy')|strtodate('M/d/yy')|unixtimestamp %}
{% if products_data.total > 0 %}
<div class="products__wrapper">
{% for result in products.results %}
{% set product = crm_object("product", result.id, "name,price,hs_lastmodifieddate,createdate") %}
{% set updated_date = product_details.hs_lastmodifieddate|strtodate('M/d/yy')|unixtimestamp %}
{% set created_date = product_details.createdate|strtodate('M/d/yy')|unixtimestamp %}
@NickDeckerDevs
NickDeckerDevs / workflow-year-month-since-date.js
Last active February 14, 2023 17:06
years months since date in javascript hubspot
// this will export out a 8 years 6 months since date
exports.main = async (event, callback) => {
// you can change these to yr, yrs, mo, mos if you would like
const terms = {
year: 'year',
yearPlural: 'years',
month: 'month',
monthPlural: 'months'
}
@NickDeckerDevs
NickDeckerDevs / workflow-associate-contacts-from-a-parent company-to-child companies.js
Last active January 14, 2023 20:12
HubSpot workflow to associate contacts from a parent company to child companies
const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
// Created by Nathan De Long @ HubSpot, 1/14/2023
// This code is provided as-is, please test this code prior to using it in a live workflow in your environment.
// modified by nick decker @ deckerdevs 1/14/2023
// modified to unnest code and change to our coding standards, cleaning it up etc
// get the associated contacts for the parent company. note, trigger for this workflow is companies
@NickDeckerDevs
NickDeckerDevs / lottie-1-4-3.js
Created December 7, 2022 21:37
hold on to this for backup!
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["lottie-player"]={})}(this,(function(exports){"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var REACT_ELEMENT_TYPE;function _jsx(t,e,r,i){REACT_ELEMENT_TYPE||(REACT_ELEMENT_TYPE="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103);var a=t&&t.defaultProps,s=arguments.length-3;if(e||0===s||(e={children:void 0}),1===s)e.children=i;else if(s>1){for(var n=new Array(s),o=0;o<s;o++)n[o]=arguments[o+3];e.children=n}if(e&&a)for(var h in a)void 0===e[h]&&(e[h]=a[h]);else e||(e=a||{});return{$$typeof:REACT_ELEMENT_TYPE,type:t,key:void 0===r?null:""+r,ref:null,props:e,_owner:null}}function _asyncIterator
@NickDeckerDevs
NickDeckerDevs / hubspot-better-assocation-loop.js
Created December 7, 2022 18:04
looping through deal => contact assocations in hubspot, then associating them
const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
const hubspotClient = new hubspot.Client({
accessToken: process.env.custom_code_private_app
});
try {
@NickDeckerDevs
NickDeckerDevs / assocationapi-hubspot.js
Created December 7, 2022 17:52
workflow custom code in hubspot
const hubspot = require('@hubspot/api-client');
// adding async to this main function here
exports.main = async (event, callback) => {
// Instantiate a new HubSpot private app (secret)
const hubspotClient = new hubspot.Client({
accessToken: process.env.custom_code_private_app
});