Skip to content

Instantly share code, notes, and snippets.

View stavrossk's full-sized avatar
🎯
Focusing

Stavros Skamagkis stavrossk

🎯
Focusing
View GitHub Profile
@stavrossk
stavrossk / Functions.php
Created June 24, 2023 17:57
WooCommerce Filter Hook to Make checkout addresses fields not required in WooCommerce. All code goes in functions.php file of your active child theme.
// Billing and shipping addresses fields
add_filter( 'woocommerce_default_address_fields' , 'filter_default_address_fields', 20, 1 );
function filter_default_address_fields( $address_fields )
{
// Only on checkout page
if( ! is_checkout() ) return $address_fields;
// All field keys in this array
@stavrossk
stavrossk / woocommerce-shipping-contact.php
Created June 7, 2023 11:34 — forked from helgatheviking/woocommerce-shipping-contact.php
Add a shipping email/phone field to checkout and notify of new orders
<?php
/*
Plugin Name: WooCommerce Shipping Contact
Plugin URI: https://github.com/helgatheviking/wc-shipping-contact
Description: Add a shipping email field to checkout and notify of new orders
Version: 1.1.0
Author: Kathy Darling
Author URI: http://kathyisawesome.com
Requires at least: 4.0
Tested up to: 4.8
@echo off
IF NOT EXIST %WINDIR%\System32\GroupPolicy goto next
echo Deleting GroupPolicy folder...
RD /S /Q "%WINDIR%\System32\GroupPolicy" || goto error
echo.
:next
IF NOT EXIST %WINDIR%\System32\GroupPolicyUsers goto next2
On MacOS terminal
===============
1. Run the following command to install the express generator
~ sudo npm install express-generator -g
2. Create a folder for the application
~ mkdir azurenodejsapp
~ cd azurenodejsapp
@stavrossk
stavrossk / Simple-Gets
Created December 6, 2018 03:54 — forked from travelingtonic/Simple-Gets
Simple GET Requests Assignments
Assignments
1. Create an app that lets users choose to display between 1 and 50 random dog images, then prints the results to the console. The app should feature a form with a required input where users indicate the number of images to retrieve, and the input should default to 3. Use the endpoint described in the "DISPLAY MULTIPLE RANDOM IMAGES FROM ALL DOGS COLLECTION" section of this page of the DogAPI docs.
https://repl.it/@travelingtonic/simple-get-assignment-1
2. Building on the previous app, create an app that lets users choose to display between 1 and 50 random dog images, then loads the images in the console. This app should adhere to all of the requirements from the first one, in addition to displaying the images in the DOM.
https://repl.it/@travelingtonic/simple-get-assignment-2
3. Create an app that loads a single random image for a specific breed. This app should account for the happy case when the breed is found, as well as the unhappy case when it is not. Use the endpoint described in th
@stavrossk
stavrossk / CustomStringEscapeUtil.java
Created December 6, 2018 03:53 — forked from mutsune/CustomStringEscapeUtil.java
(Part of) custom apache commons StringEscapeUtil like PHP htmlspecialchars
final private static CharSequenceTranslator quotes = buildAggregateTranslator(Mode.ENT_QUOTES);
final private static CharSequenceTranslator noquotes = buildAggregateTranslator(Mode.ENT_NOQUOTES);
private static AggregateTranslator buildAggregateTranslator(Mode mode) {
Map<CharSequence, CharSequence> map = new HashMap<>();
if (mode == Mode.ENT_QUOTES) {
map.put("\"", "&quot;"); // " - double-quote
map.put("'", "&apos;"); // ' - apostrophe
}
@stavrossk
stavrossk / irc_games.md
Created June 4, 2018 22:14 — forked from myano/irc_games.md
This is a list of games that are playable on IRC.

List of on-IRC games

AlphaChat

  • #multirpg

BakaShiMoe

@stavrossk
stavrossk / DI.m3u
Created April 24, 2018 06:06 — forked from sim642/DI.m3u
Digitally Imported premium streams
#EXTM3U
#EXTINF:-1,Digitally Imported - Ambient
http://pub1.diforfree.org:8000/di_ambient_hi
#EXTINF:-1,Digitally Imported - Big Room House
http://pub1.diforfree.org:8000/di_bigroomhouse_hi
#EXTINF:-1,Digitally Imported - Breaks
http://pub1.diforfree.org:8000/di_breaks_hi
@stavrossk
stavrossk / Refresh page after form submitting.php
Created April 14, 2018 00:54
Sample code to refresh a web page after form submitting using PHP.
<?php
// check if the form was submitted
if ($_POST['submit_button']) {
// this means the submit button was clicked, and the form has refreshed the page
// to access the content in text area, you would do this
$a = $_POST['update'];
// now $a contains the data from the textarea, so you can do whatever with it
// this will echo the data on the page
@stavrossk
stavrossk / Passing variables and data from PHP to JavaScript using the DOM.md
Last active April 13, 2018 03:07
Passing variables and data from PHP to JavaScript using the DOM.

This method is less preferable to AJAX, but it still has its advantages. It's still relatively separated between PHP and JavaScript in a sense that there is no PHP directly in the JavaScript.

Pros Fast - DOM operations are often quick, and you can store and access a lot of data relatively quickly. Cons Potentially Unsemantic Markup - Usually, what happens is that you use some sort of to store the information, because it's easier to get the information out of inputNode.value, but doing so means that you have a meaningless element in your HTML. HTML has the element for data about the document, and HTML 5 introduces data-* attributes for data specifically for reading with JS that can be associated with particular elements. Dirties up the Source - Data that PHP generates is outputted directly to the HTML source, meaning that you get a bigger and less focused HTML source. Harder to get structured data - Structured data will have to be valid HTML, otherwise you'll have to escape and conv