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
| -- this query outputs a data visualisation to explore how many unique products people | |
| -- see on your website, and the conversion rate | |
| -- it uses Big Query SQL on a GA4Dataform events table - check https://github.com/superformlabs/ga4dataform-community | |
| with products_per_user as ( | |
| SELECT | |
| user_pseudo_id, | |
| count( distinct if(event_name = 'view_item', i.item_name, NULL) ) as n_items_viewed, | |
| max( if(event_name = 'purchase', 1, 0)) as purchaser |
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
| // get same day of the week in the last x years ago for specific date. | |
| // Default is 1 year ago, and default date is today, takes account of leap year | |
| function getPreviousYearSameDay(dateToStart = false, years = 1) { | |
| const date = dateToStart ? new Date(dateToStart) : new Date(); | |
| const lastYear = new Date(date.getFullYear() - years, date.getMonth(), date.getDate()); | |
| const dayDiff = date.getDay() - lastYear.getDay(); | |
| return new Date(lastYear.setDate(date.getDate() + dayDiff)); | |
| } | |
| console.log(getPreviousYearSameDay('2024-10-10', 1).toISOString()); // 2023-10-11T23:00:00.000Z |
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
| { | |
| "version": 1, | |
| "snippets": [ | |
| { | |
| "version": 1, | |
| "javascript": "const settings \u003d {\\r\\n chatGpt: {\\r\\n \\/\\/ replace with your ChatGPT API key created at https:\\/\\/platform.openai.com\\/api-keys\\r\\n apiKey: \\\u0027ENTER CHATGPT API KEY\\\u0027,\\r\\n\\r\\n \\/\\/ the OpenAI model to use\\r\\n model: \\\u0027gpt-4-turbo\\\u0027,\\r\\n },\\r\\n alsoAsked: {\\r\\n \\/\\/ replace with your AlsoAsked API key created at https:\\/\\/alsoasked.com\\/developer\\/keys\\r\\n apiKey:\\r\\n \\\u0027ENTER ALSOASKED API KEY\\\u0027,\\r\\n\\r\\n \\/\\/ the language to search in\\r\\n language: \\\u0027en\\\u0027,\\r\\n\\r\\n \\/\\/ the region to search in\\r\\n region: \\\u0027gb\\\u0027,\\r\\n\\r\\n \\/\\/ the depth of the search\\r\\n \\/\\/ 2 is the default and returns the smallest number of questions, and costs 1 credit\\r\\n \\/\\/ 3 is the maximum and returns the largest number of questions, but costs 4 credits\\r\\n depth: 2,\\r\\n\\r\\n |
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
| # Try out now at https://beta.superagent.sh/workflows | |
| workflows: | |
| - superagent: | |
| llm: gpt-4-turbo-preview | |
| name: JSON Schema generator | |
| prompt: |- | |
| Convert natural language query to JSON schema | |
| Examples: | |
| Question: List all the products launching at https://www.producthunt.com/ today |
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
| javascript:(function()%7Bjavascript%3A!function()%7Bfunction%20e(e)%7Blet%20l%3De.querySelectorAll(%22tr%22)%2Cn%3Dl%5B1%5D%3Bif(!(n%26%26(n.querySelector(%22%3Anth-child(4)%20%3E%20span%20%3E%20span%20%3E%20span%22)%7C%7Cn.querySelector(%22%3Anth-child(7)%20%3E%20span%20%3E%20span%20%3E%20span%22))))for(let%20a%3D1%3Ba%3Cl.length%3Ba%2B%2B)%7Blet%20r%3Dl%5Ba%5D%3Br.cells%5B1%5D.getAttribute(%22data-numeric-value%22)%3Blet%20i%3Dr.cells%5B2%5D.getAttribute(%22data-numeric-value%22)%2Cc%3Dr.cells%5B3%5D.getAttribute(%22data-numeric-value%22)%3Br.cells%5B4%5D.getAttribute(%22data-numeric-value%22)%3Blet%20s%3Dr.cells%5B5%5D.getAttribute(%22data-numeric-value%22)%2Co%3Dr.cells%5B6%5D.getAttribute(%22data-numeric-value%22)%2Cd%3Di%2Cu%3Ds%2Cp%3Dt(c%2Cd)%2Ch%3Dt(o%2Cu)%2Cf%3Dr.querySelector(%22%3Anth-child(4)%20%3E%20span%20%3E%20span%22)%2Cm%3Dr.querySelector(%22%3Anth-child(7)%20%3E%20span%20%3E%20span%22)%2Cg%3Ddocument.createElement(%22span%22)%2C%24%3Ddocument.createElement(%22span%22)%3Bg.innerText%3D%60%20( |
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
| # NOTE: | |
| # You can find an updated, more robust and feature-rich implementation | |
| # in Zeno Build | |
| # - Zeno Build: https://github.com/zeno-ml/zeno-build/ | |
| # - Implementation: https://github.com/zeno-ml/zeno-build/blob/main/zeno_build/models/providers/openai_utils.py | |
| import openai | |
| import asyncio | |
| from typing import Any |
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 advertools as adv | |
| import pandas as pd | |
| key = 'YOUR_GOOGLE_KEY' | |
| brands = [ | |
| 'nike', | |
| 'adidas', | |
| 'puma', | |
| 'asics', |
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 plotly.graph_objects as go | |
| import pandas as pd | |
| def serp_heatmap(df, num_domains=10, select_domain=None): | |
| df = df.rename(columns={'domain': 'displayLink', | |
| 'searchTerms': 'keyword'}) | |
| top_domains = df['displayLink'].value_counts()[:num_domains].index.tolist() | |
| top_domains = df['displayLink'].value_counts()[:num_domains].index.tolist() | |
| top_df = df[df['displayLink'].isin(top_domains) & df['displayLink'].ne('')] |
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
| # !pip install --upgrade transformers plotly pandas | |
| import plotly.graph_objects as go | |
| import pandas as pd | |
| pd.options.display.max_columns = None | |
| from transformers import pipeline | |
| unmasker = pipeline('fill-mask', model='bert-base-uncased') | |
| results = [] | |
| cars = ['mercedes', 'audi', 'bmw', 'volkswagen', 'ford', 'toyota', |
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
| # TIPS | |
| 1) Remove the count function and paste into dev tools to test further | |
| 2) To spot additonal oportunities swap the img selector to video, iframe or wildcards | |
| 3) Render JS in SF to discover all images and spot differences | |
| 4) Spot check source to find different lazy loading libraries e.g. Lazysizes, JQuery Lazy, yall.js etc | |
| # CAVEATS | |
| 1) Don't forget to check background CSS images | |
| 2) Other implimentaiton techniques may exist, adapt this approach to suit your needs e.g yall.js - lazy-bg-loaded |
NewerOlder