Skip to content

Instantly share code, notes, and snippets.

View junaidkbr's full-sized avatar
🔥

Junaid Ahmed junaidkbr

🔥
View GitHub Profile
@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=/'
}
@junaidkbr
junaidkbr / delete-all-woocommerce-products.php
Created February 11, 2018 20:45 — forked from mikaelz/delete-all-woocommerce-products.php
Remove all WooCommerce products from database via SQL
<?php
require dirname(__FILE__).'/wp-blog-header.php';
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')");
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'");
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)");
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))");
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')");
<?php
/*
* Create order dynamically
*/
add_action( 'woocommerce_before_checkout_form', 'create_order' );
function create_order() {
global $woocommerce;