Skip to content

Instantly share code, notes, and snippets.

View adam-sandor's full-sized avatar

Ádám Sándor adam-sandor

View GitHub Profile
@adam-sandor
adam-sandor / checkout-logging.php
Last active October 30, 2023 20:49
checkout-logging.php
<?php
$PRIORITY=-1;
/**
* Log reaching the thank-you page with the order number
*/
add_action( 'woocommerce_thankyou', function($order_id) {
printLogMessage("Thank you page reached (order_id: " . $order_id . ")");
}, $PRIORITY, 1 );
@adam-sandor
adam-sandor / gist:d63d21a2f8dee9f7a9a6e48c5d2fceb7
Last active October 28, 2023 16:26
Woocommerce checkout printnode error
[Sat Oct 28 14:29:10.875915 2023] [proxy_fcgi:error] [pid 20448:tid 140469874956032] [client 37.191.54.101:0] AH01071: Got error 'PHP message: modified_date was called incorrectly. Order properties should not be accessed directly. Backtrace: require('wp-blog-header.php'), requir
e_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::do_wc_ajax, do_action('wc_ajax_checkout'), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Checkout->p
rocess_order_without_payment, WC_Order->payment_complete, do_action('woocommerce_payment_complete'), WP_Hook->do_action, WP_Hook->apply_filters, WooCommerce_Simba_PrintOrders_1_0->woocommerce_payment_complete, WooCommerce_Simba_PrintOrders_1_0->print_order_or_schedule, WooCommer
ce_Simba_PrintOrders_1_0->print_go, WooCommerce_Simba_PrintOrders_1_0->woocommerce_process_order, WooCommerce_Simba_PrintOrders_Sources_1_0->getdocument_woocommerce_pips_packing_slip,
2023-09-28T10:50:31+00:00 INFO 12726: /my-account/
2023-09-28T10:50:38+00:00 INFO 12726: /noonehastobeadalone/
2023-09-28T10:50:52+00:00 INFO 12726: /bead-shop/
2023-09-28T10:51:03+00:00 INFO 12726: /product-category/beading-tutorials/
2023-09-28T10:51:15+00:00 INFO 12726: /product-category/beading-tutorials/noonehastobeadalone-tutorials/
2023-09-28T10:51:40+00:00 INFO 12726: /product-category/boxes-collections-special-deals/
2023-09-28T10:52:06+00:00 INFO 12726: /product-category/boxes-collections-special-deals/academy-single-boxes/
2023-09-28T10:52:29+00:00 INFO 12726: /product-category/advent-calendar/
2023-09-28T10:52:44+00:00 INFO 12726: /?wc-ajax=add_to_cart
2023-09-28T10:52:50+00:00 INFO 12726: /noonehastobeadalone/
@adam-sandor
adam-sandor / rule3.rego
Created July 8, 2021 16:11
Rego rule 3 - Only managers from the employee_managers list can create employees
employee_managers := {"janedoe@styra.com","alicesmith@styra.com","davidholme@styra.com"}
allow {
input.attributes.request.http.method == "POST"
input.parsed_path[0] = "employees"
jwt.valid
jwt.payload.Role == "manager"
jwt.payload.Group == input.parsed_body.userGroup
employee_managers[_] == jwt.payload.sub #is the subject in the employee_managers set?
}
@adam-sandor
adam-sandor / rule2.rego
Created July 8, 2021 16:10
Rego rule 2 - Managers can create employees only in their own group
allow {
input.attributes.request.http.method == "POST"
input.parsed_path[0] == "employees"
jwt.valid
jwt.payload.Role == "manager"
jwt.payload.Group == input.parsed_body.userGroup
}
@adam-sandor
adam-sandor / rule1.rego
Created July 8, 2021 16:09
Rego rule - Only managers can create employees
allow {
input.attributes.request.http.method == "POST"
input.parsed_path[0] == "employees"
jwt.valid
jwt.payload.Role == "manager"
}
@adam-sandor
adam-sandor / envoy-ext_auth-request.json
Created July 8, 2021 16:08
Envoy ext_auth request to OPA
{
"attributes": {
"destination": {
"address": {
"socketAddress": {
"address": "10.36.4.39",
"portValue": 8080
}
},
"principal": "spiffe://cluster.local/ns/employees/sa/default"
@adam-sandor
adam-sandor / sample-http-request.txt
Created July 8, 2021 16:06
Sample HTTP Request with Kubernetes metadata
POST https://employee-manager/employee
BASIC HTTP:
host: employee-manager
path: employees
port: 80
KUBERNETES:
source:
serviceaccount: payroll
namespace: payroll
ip: 10.3.4.6
@adam-sandor
adam-sandor / Dockerfile
Created July 2, 2021 10:25
Multistage Docker build with Maven
FROM maven:3 AS build
WORKDIR /build
COPY pom.xml .
RUN mkdir -p src/main/java
COPY FakeMain.java src/main/java #without this mvn package will fail
RUN mvn package
COPY src ./src
After setting the number of replicas to 7 I get the following exception. This seems to be caused simply by the update for 7 replicas coming
too soon after the update for 5.
2020-11-30 22:47:19,694 i.j.t.DeploymentEventSource [INFO ] Event received for action: MODIFIED, Deployment: test-tomcat1 (rr=5)
2020-11-30 22:47:19,730 i.j.t.DeploymentEventSource [INFO ] Event received for action: MODIFIED, Deployment: test-tomcat1 (rr=7)
2020-11-30 22:47:19,832 i.j.t.TomcatController [INFO ] Creating or updating Service test-tomcat1 in tomcat-demo
2020-11-30 22:47:19,953 i.j.t.TomcatController [INFO ] Updating status of Tomcat test-tomcat1 in namespace tomcat-demo to 5 ready replicas
2020-11-30 22:47:19,985 i.j.t.TomcatController [INFO ] Updating status of Tomcat test-tomcat1 in namespace tomcat-demo to 7 ready replicas
2020-11-30 22:47:20,014 i.j.o.p.EventDispatcher [ERROR] Error during event processing ExecutionScope{events=[CustomResourceEvent{action=MODIFIED, resource=[ name=test-tomcat1, kind=D