Skip to content

Instantly share code, notes, and snippets.

View junaidkbr's full-sized avatar
🔥

Junaid Ahmed junaidkbr

🔥
View GitHub Profile
@junaidkbr
junaidkbr / gist:88f0677a7e2ca3e1c8b0a38768553cf1
Last active January 2, 2025 15:24
Open Shopify editor for Shopify resources (page, product, collection, article) from the frontend
const shopName = window.Shopify.shop.replace(".myshopify.com", "");
const { rtyp: resourceType, rid: resourceId } = window.__st;
if (["product", "collection", "page", "article"].includes(resourceType)) {
const url = `https://admin.shopify.com/store/${shopName}/${resourceType}s/${resourceId}`;
window.open(url, "_blank");
} else {
alert("Unsupported resource type");
}
@junaidkbr
junaidkbr / gist:6638192d65fc03e2e55a3d9f9a060f98
Last active January 2, 2025 15:23
Shortcut: Open Shopify pages in Customizer from the frontend
const shopName = window.Shopify.shop.replace(".myshopify.com", "");
const themeId = window.Shopify.theme.id;
let previewPath = "";
if (window.location.pathname !== "/") {
previewPath = encodeURIComponent(window.location.pathname);
}
const customizerUrl = `https://admin.shopify.com/store/${shopName}/themes/${themeId}/editor?previewPath=${previewPath}`;
window.open(customizerUrl, '_blank');
@junaidkbr
junaidkbr / linkedin-remove-connection.js
Last active August 30, 2022 12:20
Unfollow and Remove LinkedIn Connection
/**
* Quickly unfollow and remove from connections
* the LinkedIn connection you're currently viewing
*
* Enter the source code in browser Dev Tools or
* bookmark the bookmarlet version for one-click solution
*/
/* Source Code Start */
const actionsWrapper = document.querySelector('#main .pvs-profile-actions > *:last-child > div');
{% comment %}
Get page handle based on page type
{% endcomment %}
{% liquid
assign page_handle = ''
assign page_type = request.page_type
case page_type
when 'index'
assign page_handle = 'index'
{% comment %}
Logic to ignore a tag in the loop, based on a provided set of comma separated tags.
@param settings.ignore_tags Comma separated tags to ignore
{% endcomment %}
{% liquid
assign can_ignore_tag = false
assign tag_handle = tag | handle
assign tags_to_ignore = settings.ignore_tags | split: ','
const twoSum = (numbers, target) => {
let indices = [];
for (let i = 0; i < numbers.length; i++) {
for (let j = 0; j < numbers.length; j++) {
if (i == j) {
continue;
}
if ((numbers[i] + numbers[j]) == target) {
@junaidkbr
junaidkbr / youtube-video-thumbnail.liquid
Created April 5, 2020 23:58
Get Youtube video thumbnail from Youtube URL in Shopify Liquid
{% comment %} We assume that we have the youtube video in form of URL {% endcomment %}
{% assign video_url = 'https://www.youtube.com/watch?v=ScMzIvxBSi4' %}
{% assign thumbnail_url = '' %}
{% comment %} First of all, we get last part of the URL that's supposedly the Youtube Video ID {% endcomment %}
{% assign video_id = video_url | split: '/' | last %}
{% comment %} but we need strip any extra URL params {% endcomment %}
{% assign video_id = video_id | split: '?' | first %}
@junaidkbr
junaidkbr / scrape-ada-org.js
Last active February 27, 2019 16:52
Scrape doctor information from ada.org
/*
This script will scrape and display the doctors (available on a search page) information in the browser console.
Example search results page: https://findadentist.ada.org/search-results?address=22060
How to use:
1. Search for doctors on https://findadentist.ada.org
2. When you get a list of doctors for your search criteria, open browser developer console
How to open console in Firefox: https://developer.mozilla.org/en-US/docs/Tools/Browser_Console#Opening_the_Browser_Console
How to open Console in Chrome: https://developers.google.com/web/tools/chrome-devtools/console/
$.extend(Tipped.Behaviors, {
'custom-speed': {
fadeIn: 250,
fadeOut: 250
}
});
Tipped.create('.tippy', {
behavior: 'custom-speed',
size: 'large'
@junaidkbr
junaidkbr / cookies.js
Last active November 19, 2019 05:58
Handling cookies with Javascript
/**
* Creates or Updates a cookie
*/
function setCookie(name, value, expiry /* in days */ ) {
var d = new Date()
d.setTime(d.getTime() + (expiry * 24 * 60 * 60 * 1000))
var expires = 'expires=' + d.toUTCString()
document.cookie = name + '=' + value + ';' + expires + ';path=/'
}