Skip to content

Instantly share code, notes, and snippets.

const parseAmzImageUrl = (imgurl) => {
// let imageURL =
// 'https://m.media-amazon.com/images/I/A1EHx4FHFjL._CLa%7C2140%2C2000%7CB1hNfKQcFOS.png%7C0%2C0%2C2140%2C2000%2B0.0%2C0.0%2C2140.0%2C2000.0._UL1500_.png';
let imageURL = decodeURIComponent(imgurl);
let imgData = imageURL.split('/I/');
let startURL = imgData[0];
imgData = imgData[1];
let fileInfo = path.parse(imageURL);
@shrimp2t
shrimp2t / app.js
Created September 19, 2019 02:58 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
yarn
yarn install v1.17.3
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
warning "firebase > @firebase/database@0.3.8" has unmet peer dependency "@firebase/app-types@0.x".
warning "firebase > @firebase/firestore@0.9.2" has unmet peer dependency "@firebase/app-types@0.x".
warning "firebase > @firebase/functions@0.3.3" has unmet peer dependency "@firebase/app-types@0.x".
warning "firebase > @firebase/messaging@0.3.7" has unmet peer dependency "@firebase/app-types@0.x".
warning "firebase > @firebase/storage@0.2.4" has unmet peer dependency "@firebase/app-types@0.x".
{
"id": 799,
"name": "Ship Your Idea",
"slug": "ship-your-idea-22",
"permalink": "https://example.com/product/ship-your-idea-22/",
"date_created": "2017-03-23T17:03:12",
"date_created_gmt": "2017-03-23T20:03:12",
"date_modified": "2017-03-23T17:03:12",
"date_modified_gmt": "2017-03-23T20:03:12",
"type": "variable",
<?php
/**
* Plugin Name: Disable HTTP Request SSL Veryify
* Plugin URI: #
* Description: A products manager for woocommerce
* Version: 1.0.0
* Author: shrimp2t
* Author URI: https://github.com/shrimp2t/
* Text Domain:
*/
@shrimp2t
shrimp2t / Grunt.js
Last active May 3, 2019 09:01
Grunt JS
module.exports = function( grunt ) {
'use strict';
var pkgInfo = grunt.file.readJSON('package.json');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
rtlcss: {
options: {
// rtlcss options
config: {
<?php
class Wishlist_Plus_Product {
public function __construct() {
add_action( 'woocommerce_single_product_summary', array( $this, 'add_button_hook' ), 35 );
add_action( 'woocommerce_after_shop_loop_item', array( $this, 'add_button_hook' ), 100 );
add_action( 'wp_footer', array( $this, 'wishlist_modal_template' ), 100 );
}
public function wishlist_modal_template() {
if ( wishlist_plus()->get_limit() <= 1 ) {
<?php
// The function to count words in Unicode strings
function count_unicode_words( $unicode_string ){
// First remove all the punctuation marks & digits
$unicode_string = preg_replace('/[[:punct:][:digit:]]/', '', $unicode_string);
// Now replace all the whitespaces (tabs, new lines, multiple spaces) by single space
$unicode_string = preg_replace('/[[:space:]]/', ' ', $unicode_string);
// The words are now separated by single spaces and can be splitted to an array
// I have included \n\r\t here as well, but only space will also suffice
$words_array = preg_split( "/[\n\r\t ]+/", $unicode_string, 0, PREG_SPLIT_NO_EMPTY );
@shrimp2t
shrimp2t / extensions.json
Last active June 5, 2021 01:53
VSCode's Settings - Syncing
[
{
"id": "annsk.alignment",
"name": "alignment",
"publisher": "annsk",
"version": "0.3.0"
},
{
"id": "bmewburn.vscode-intelephense-client",
"name": "vscode-intelephense-client",
@shrimp2t
shrimp2t / ruleset.xml
Last active January 29, 2019 18:56
Copy it in to ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards/WordPress/ruleset.xml
<?xml version="1.0"?>
<ruleset name="WordPress" namespace="WordPress">
<description>WordPress Coding Standards</description>
<autoload>./PHPCSAliases.php</autoload>
<!--<rule ref="WordPress-Core"/> -->
<rule ref="WordPress-Core">
<exclude name="Generic.Commenting.DocComment.MissingShort" />