Skip to content

Instantly share code, notes, and snippets.

@shayanabbas
shayanabbas / gist:6166967
Last active December 20, 2015 17:09
Replaces all spaces and stupid character from a string, this function can be used while creating SEO url.
function safename($title){
// replaces every stupid character form a string with - ;
$title = str_replace("&", "and", $title);
$arrStupid = array('.com', '(tm)', ' ', '*', "'s", '"', ",", ":", ";", "@", "#", "(", ")", "?", "!", "_",
"$","+", "=", "|", '/', "~", "`s", "`", "\\", "^", "[","]","{", "}", "<", ">", "%", "™");
$title = htmlentities($title);
$title = preg_replace('/&([a-zA-Z])(.*?);/','$1',$title); // get rid of bogus characters
$title = strtolower("$title");
$title = str_replace(".", "", $title);
@shayanabbas
shayanabbas / blockstack.txt
Created March 25, 2018 14:10
Blockstack Verification
Verifying my Blockstack ID is secured with the address 16sf7DsH4dVYBSEFfxCsDctPxpUbHx8rj2 https://explorer.blockstack.org/address/16sf7DsH4dVYBSEFfxCsDctPxpUbHx8rj2
@shayanabbas
shayanabbas / Tietosuojaseloste
Created September 9, 2019 09:03
Tietosuojaseloste (Privacy Policy)
<p>Tämä seloste sisältää EU:n yleisen tietosuoja-asetuksen (2016/679) 13 ja 14 artiklan edellyttämiä tietoja henkilötiedoista, joita käsittelemme [DOMAIN]- verkkosivupalveluumme (jäljempänä ”<strong>Palvelu</strong>”) liittyen.</p>
<ol>
<li>
<p>Rekisterinpitäjä</p>
<p>[Yrityksen nimi]
<br /> Y-tunnus: [Yrityksen y-tunnus]
<br /> Osoite: [Yrityksen osoite]
<br /> Kotipaikka: Helsinki
<br />
<br />Yhteyshenkilö
# We'll be installing Homebrew in the /opt directory.
cd /opt
# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew
# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
Running bash [-c /var/folders/1p/_6dkh_gd1lv_nvpdxrv4jlw00000gn/T/test_ddev.sh]
OS Information: Darwin My-MacBook-Pro-Work.local 22.0.0 Darwin Kernel Version 22.0.0: Mon Aug 1 06:31:07 PDT 2022; root:xnu-8792.0.207.0.6~26/RELEASE_X86_64 x86_64
ProductName: macOS
ProductVersion: 13.0
BuildVersion: 22A5321d
User information: uid=501(myuser) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae),701(com.apple.sharepoint.group.1)
DDEV version: ITEM VALUE
DDEV version v1.20.0
architecture amd64
db drud/ddev-dbserver-mariadb-10.4:v1.20.0
myuser@Myuser-MacBook-Pro-Work mydummyproject % ddev logs
+ set -o errexit nounset pipefail
+ rm -f /tmp/healthy
+ DDEV_PHP_VERSION=7.4
+ DDEV_WEBSERVER_TYPE=apache-fpm
+ '[' -n 7.4 ']'
+ update-alternatives --set php /usr/bin/php7.4
+ ln -sf /usr/sbin/php-fpm7.4 /usr/sbin/php-fpm
+ export PHP_INI=/etc/php/7.4/fpm/php.ini
+ PHP_INI=/etc/php/7.4/fpm/php.ini
myuser@Myuser-MacBook-Pro-Work mydummyproject % ddev debug test
Running bash [-c /var/folders/1p/_6dkh_gd1lv_nvpdxrv4jlw00000gn/T/test_ddev.sh]
OS Information: Darwin Myuser-MacBook-Pro-Work.local 22.0.0 Darwin Kernel Version 22.0.0: Mon Aug 1 06:31:07 PDT 2022; root:xnu-8792.0.207.0.6~26/RELEASE_X86_64 x86_64
ProductName: macOS
ProductVersion: 13.0
BuildVersion: 22A5321d
User information: uid=501(myuser) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae),701(com.apple.sharepoint.group.1)
DDEV version: ITEM VALUE
DDEV version v1.20.0
architecture amd64
@shayanabbas
shayanabbas / How to Rename and Migrate WordPress Taxonomies Using WP-CLI
Last active June 15, 2023 13:29
The script provided below is a WP-CLI command script that renames the 'industry' taxonomy to 'segment' and migrates all terms and associated posts.
In our example, we're migrating the taxonomy 'industry' to a new taxonomy called 'segment'. Both these taxonomies are related to a custom post type 'case'.
@shayanabbas
shayanabbas / Extracting data from the Matomo Tracking API, processing it, translating it to a CSV file, and sending it daily via email.js
Created June 22, 2023 11:19
Make sure to replace the placeholders 'YOUR_MATOMO_SERVER', 'YOUR_SITE_ID', 'YOUR_AUTH_TOKEN', 'your_email@example.com', 'recipient@example.com', 'your_smtp_host', 'your_smtp_username', and 'your_smtp_password' with the actual values specific to your setup.
const fs = require('fs');
const request = require('request');
const csvWriter = require('csv-writer').createObjectCsvWriter;
const nodemailer = require('nodemailer');
// Matomo API endpoint and parameters
const apiUrl = 'https://your-matomo-server.com/matomo.php';
const siteId = 'YOUR_SITE_ID';
const tokenAuth = 'YOUR_AUTH_TOKEN';
const dateRange = 'previous30'; // Adjust the date range as needed
@shayanabbas
shayanabbas / Import Products to WooCommerce using WordPress REST API.md
Created January 11, 2024 22:01
Import Products to WooCommerce using WordPress REST API

You can use the built-in WordPress REST API to import products into WooCommerce. WooCommerce extends the WordPress REST API with its own specific endpoints, allowing you to create, read, update, and delete products programmatically. Here's how you can do this:

Enable the WordPress REST API: Ensure that the WordPress REST API is enabled on your site. It is enabled by default in recent WordPress versions.

Authentication: To use the REST API, especially for writing data such as importing products, you'll need to authenticate. You can use one of the following methods:

Basic Authentication: This is simpler for development purposes but not recommended for production due to security concerns unless used over HTTPS. OAuth Authentication: More secure and suitable for production environments. Understand WooCommerce REST API Endpoints: WooCommerce adds several endpoints to the WordPress REST API for handling products. The endpoint for products typically looks like this: /wp-json/wc/v3/products.