Skip to content

Instantly share code, notes, and snippets.

@strarsis
strarsis / functions.php
Created April 13, 2023 14:06 — forked from yanknudtskov/functions.php
Example on how to meta query ACF repeater fields
<?php
add_shortcode( 'user_company_link', 'yanco_user_company_link' );
function yanco_user_company_link() {
if( ! is_user_logged_in() ) {
return;
}
$html = '';
function Child({ onClick }) {
return <button onClick={onClick} type="button">Child Button</button>;
}
export default function Parent() {
const onClick = () => {
console.log('I\'m in the parent, but the child was clicked');
};
return (
@strarsis
strarsis / max_width_email.html
Created September 25, 2020 06:13 — forked from elidickinson/max_width_email.html
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@strarsis
strarsis / dumprequest.php
Created April 16, 2018 15:28 — forked from magnetikonline/dumprequest.php
PHP script to dump full HTTP request to file (method, HTTP headers and body).
<?php
// https://gist.github.com/magnetikonline/650e30e485c0f91f2f40
class DumpHTTPRequestToFile {
public function execute($targetFile) {
$data = sprintf(
"%s %s %s\n\nHTTP headers:\n",
$_SERVER['REQUEST_METHOD'],
@strarsis
strarsis / dom-insert-after.php
Created March 26, 2018 22:27 — forked from deathlyfrantic/dom-insert-after.php
why doesn't the DOM spec include an insertAfter method, srsly guys
<?php
/** Inserts a new node after a given reference node. Basically it is the complement to the DOM specification's
* insertBefore() function.
* @param \DOMNode $newNode The node to be inserted.
* @param \DOMNode $referenceNode The reference node after which the new node should be inserted.
* @return \DOMNode The node that was inserted.
*/
function insertAfter(\DOMNode $newNode, \DOMNode $referenceNode)
{
if($referenceNode->nextSibling === null) {
@strarsis
strarsis / wpdb-transactions
Created March 14, 2018 20:56 — forked from nciske/wpdb-transactions
MySQL database transaction, using the WordPress database object $wpdb. Requires the InnoDB table format.
<?php
global $wpdb;
// Start Transaction
$wpdb->query( "START TRANSACTION" );
// Do some expensive/related queries here
//$wpdb->query("DELETE FROM table WHERE form_id = '1' ");
//$wpdb->query("DELETE FROM data WHERE form_id = '1' ");
// set $error variable value in error handling after $wpdb modifications
@strarsis
strarsis / gist:c900cb342140ec7d1439b35c05b1cd26
Created March 11, 2018 01:33 — forked from kuyseng/gist:2792080
javascript: indesign progress bar
function index_progress_bar(title) {
var w = new Window("palette", title, undefined);
w.orientation = "column";
var text_group = w.add("group");
text_group.orientation = "column";
var file_name = text_group.add("statictext", [0,0,350,20], "calculating..");
var remain = text_group.add("statictext", [0,0,350,20], "Remain: ..");
text_group.alignChildren = "left";
var progressbar = w.add("progressbar", undefined, 0, 100);
progressbar.preferredSize = [350,20];
@strarsis
strarsis / indd_page_extract.jsx
Created March 11, 2018 01:15 — forked from bastien/indd_page_extract.jsx
Extracting a page from an InDesign document (2 different approaches)
var doc = app.activeDocument;
if(doc.saved == true)
{
extract(2);
}
else
{
alert("Save you file.");
}
@strarsis
strarsis / functions.php
Created March 5, 2018 22:53 — forked from kloon/functions.php
WooCommerce Dropdown Product Quantity, fully compatible with Min/Max quantities extension
<?php
// Place the following code in your theme's functions.php file
// override the quantity input with a dropdown
function woocommerce_quantity_input() {
global $product;
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => apply_filters( 'woocommerce_quantity_input_max', '', $product ),
@strarsis
strarsis / docker-env
Created January 16, 2018 15:46 — forked from mmarchini/docker-env
Docker Env converter from Windows to WSL
#!/usr/bin/env python3
from subprocess import run, PIPE
completed_process = run(["docker-machine.exe", "env", "--shell", "bash"], stdout=PIPE)
docker_env = completed_process.stdout.decode("ascii")
for line in docker_env.split("\n"):
if "DOCKER_CERT_PATH" in line: