Skip to content

Instantly share code, notes, and snippets.

View Moriort's full-sized avatar
🏠
Working from home

Moriort

🏠
Working from home
  • Digital Strong Locking
  • Antofagasta
View GitHub Profile
@yanknudtskov
yanknudtskov / woocommerce-update-prices.sql
Last active August 1, 2023 23:45
Queries for updating all prices including variations in WooCommerceIn this instance all prices are subtracted 20% (0.8)#woocommerce #mysql
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_regular_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_sale_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_regular_price_tmp' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_sale_price_tmp' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_price_tmp' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_min_variation_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_max_variation_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHERE meta_key = '_min_variation_regular_price' AND meta_value != ''
UPDATE wp_postmeta SET meta_value = meta_value*0.8 WHE
@joepie91
joepie91 / sessions.md
Last active October 9, 2024 15:34
Introduction to sessions

While a lot of Node.js guides recommend using JWT as an alternative to session cookies (sometimes even mistakenly calling it "more secure than cookies"), this is a terrible idea. JWTs are absolutely not a secure way to deal with user authentication/sessions, and this article goes into more detail about that.

Secure user authentication requires the use of session cookies.

Cookies are small key/value pairs that are usually sent by a server, and stored on the client (often a browser). The client then sends this key/value pair back with every request, in a HTTP header. This way, unique clients can be identified between requests, and client-side settings can be stored and used by the server.

Session cookies are cookies containing a unique session ID that is generated by the server. This session ID is used by the server to identify the client whenever it makes a request, and to associate session data with that request.

*S

@bekarice
bekarice / wc-prevent-checkout-for-cart-with-specific-category.php
Last active June 29, 2023 20:32
Prevents checkout if the WooCommerce cart only contains items from a specific category
<?php // only copy this line if needed
/**
* Renders a notice and prevents checkout if the cart
* only contains products in a specific category
*/
function sv_wc_prevent_checkout_for_category() {
// set the slug of the category for which we disallow checkout
$category = 'clothing';
<?php
// disable yoast seo nag messages
// via https://wordpress.org/support/topic/turn-off-yoast-seo-has-been-updated-to-version-message
if ( class_exists( 'Yoast_Notification_Center' ) ) {
remove_action( 'admin_notices', array( Yoast_Notification_Center::get(), 'display_notifications' ) );
remove_action( 'all_admin_notices', array( Yoast_Notification_Center::get(), 'display_notifications' ) );
}
?>
@Joseph-N
Joseph-N / _user.html.erb
Last active April 19, 2019 12:50
Rails - Load more with jQuery and Ajax Code snippets - Tutorial link http://josephndungu.com/tutorials/rails-load-more-results-using-jquery-ajax
<div class="record" data-id="<%= user.id %>">
<p><b>ID: </b> <%= user.id %></p>
<p><b>Name: </b> <%= user.name %></p>
<p><b>Location: </b> <%= user.location %> </p>
<p><%= link_to 'Show', user %> | <%= link_to 'Edit', edit_user_path(user) %> | <%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %> </p>
</div>
@dejanmarkovic
dejanmarkovic / NOBLOGREDIRECT explained and fix
Created January 8, 2014 20:15
NOBLOGREDIRECT explained and fix
A little explanation for those who have no idea what NOBLOGREDIRECT is.
The define(‘NOBLOGREDIRECT’, ‘%siteurl%’); inside of the wp-config.php makes it so that when someone enters a subdomain that does not exist on your site to redirect to whatever url you wish it to. You can use this to have it either go to a specific FAQ page or directly back to the main root installation, anywhere you want to direct it. the %siteurl% can be replaced for example define(‘NOBLOGREDIRECT’, ‘http://frumph.net/FAQ/site-create’);
When someone in their browser tries to go to (for example) http://badsubdomain.frumph.net/ a subomain which doesn’t exist, it will go to what is defined in NOBLOGREDIRECT.
Without using NOBLOGREDIRECT the (for example) http://badsubdomain.frumph.net/ – which is a subdomain that doesn’t exist would direct to the signup page asking which reports whether or not the user can create the bad subdomain in question. This is fine, there’s nothing wrong with it redirecting to the signup page if someone put
@raelgc
raelgc / Email Server (Windows Only).md
Last active March 8, 2025 06:06
Setup a Local Only Email Server (Windows Only)
@jazzido
jazzido / index.html
Last active January 10, 2022 03:52
Glowing text effect with CSS3
<html>
<head>
<style type="text/css">
.glow {
-webkit-animation-duration: 1s;
-webkit-animation-name: glow;
-webkit-animation-direction: alternate;
-webkit-animation-iteration-count: infinite;
animation-duration: 1s;
animation-name: glow;
@amolpujari
amolpujari / active_admin.rb
Created March 26, 2013 09:47
activeadmin timestamps columns, and other customizations
module ActiveAdmin
module Views
class IndexAsTable < ActiveAdmin::Component
class IndexTableFor < ::ActiveAdmin::Views::TableFor
def timestamps_columns
column :created_at, :sortable => :created_at do |resource|
resource.created_at and resource.created_at.strftime('%b %-d %Y, %l %P')
end
column :updated_at, :sortable => :updated_at do |resource|
@theo-bittencourt
theo-bittencourt / Active Admin Super Example of Resource Customization.rb
Created September 12, 2012 04:10
Active Admin: Super Example of Resource Customization
ActiveAdmin.register Event do
#Menu display index
menu :priority => 1
#Scopes
scope :all
scope :pending
scope :approved
scope :rejected
scope :cancelled