Skip to content

Instantly share code, notes, and snippets.

View a1iraxa's full-sized avatar

Ali Raza a1iraxa

View GitHub Profile
@a1iraxa
a1iraxa / raza-woocommerce-custom-field-in-brands-and-category.php
Created September 5, 2024 13:00
Add custom fields in WooCommerce Brand and Category
<?php
// Add WYSIWYG editor to product category add/edit form
function x2a_add_category_short_description_field() {
?>
<div class="form-field">
<label for="x2a_short_description"><?php _e('Short Description', 'text-domain'); ?></label>
<?php
wp_editor('', 'x2a_short_description', array(
'textarea_name' => 'x2a_short_description',
@a1iraxa
a1iraxa / raza-server-2-server-download.php
Created September 5, 2024 12:59
Server 2 Server Moving Files in PHP
<?php
echo "Downloading...";
$source = 'https://abc.com/source/directory/and/path/to/large-file.zip';
$destination = "/home/name/public_html/destination/path/large-file.zip";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@a1iraxa
a1iraxa / raza-COD-WP-WC-Filter.php
Created September 5, 2024 12:56
Wordpress WooCommerce Filter for woocommerce_cart_calculate_fees
<?php
add_action( 'woocommerce_cart_calculate_fees', 'raza_fee_based_on_payment_method_and_total' );
function raza_fee_based_on_payment_method_and_total( $cart ) {
if ( is_admin() && ! defined('DOING_AJAX') ){
return;
}
$threshold_amount = 300; // Total amount to reach for no fees
@a1iraxa
a1iraxa / publickey-git-error.markdown
Created July 6, 2023 05:46 — forked from adamjohnson/publickey-git-error.markdown
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "your_email@example.com". Th
@a1iraxa
a1iraxa / async-await-forEach-alternatives.md
Created October 15, 2021 15:27 — forked from joeytwiddle/async-await-forEach-alternatives.md
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

You could just make your own pg_dump directly from your Heroku database.
First, get your postgres string using `heroku config:get DATABASE_URL`.
Look for the Heroku Postgres url (example: `HEROKU_POSTGRESQL_RED_URL: postgres://user3123:passkja83kd8@ec2-117-21-174-214.compute-1.amazonaws.com:6212/db982398`), which format is `postgres://<username>:<password>@<host_name>:<port>/<dbname>`.
Next, run this on your command line:
pg_dump --host=<host_name> --port=<port> --username=<username> --password --dbname=<dbname> > output.sql
@a1iraxa
a1iraxa / SSL-certs-OSX.md
Created June 28, 2021 16:45 — forked from croxton/SSL-certs-OSX.md
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

DNS.1   = my-project.dev

Additional FQDNs can be added if required:

@a1iraxa
a1iraxa / copy.js
Created April 15, 2021 23:08 — forked from GarySwift/copy.js
5 ways copy text to clipboard using jQuery (+ JavaScript)
jQuery(document).ready(function($) {
// If a copy clickable input is clicked
// input value will be highlighted and copied to clipboard
$('body').on('click', 'input.js-click-to-copy-input', function(e) {
copy_input( this );
});
// If a button to copy an input is clicked
// associated input value will be highlighted and copied to clipboard
$('body').on('click', 'a.js-click-to-copy-link', function(e) {
@a1iraxa
a1iraxa / List.md
Created July 24, 2020 16:50 — forked from msurguy/List.md
List of open source projects made with Laravel

Other people's projects:

My projects (tutorials are on my blog at http://maxoffsky.com):

MySQL Cheatsheet

This is a collection of the most common commands I run while administering Mysql databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Mysql has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu 14.04

https://help.ubuntu.com/14.04/serverguide/mysql.html

sudo apt-get update