Skip to content

Instantly share code, notes, and snippets.

@idokd
idokd / postman-github-repos-batch-transfer
Last active November 1, 2021 18:29
Github Repository Ownership Transfer via Postman
# This script is to be used in Postman if you wish to transfer ownership of your repository in a batch
# Example; downgrading from organization account (25usd min) to pro user (7usd) monthly and keeping all
# your private repositories
# Instead of complicate with scripts etc. just use postman
# the repos api will list only 25 at a time, so you should run this script a few times if you have more
# repositories to transfer
GET /orgs/### CURRENT OWNER REPOSITORY ###/repos HTTP/1.1
Host: api.github.com
Authorization: token ### GITHUB API TOKEN HERE ###
@idokd
idokd / scrap-ca-to-bundle.sh
Last active January 21, 2022 14:58
Scrap site for its certificates, validate and create a ca bundle, for the use in downloading a local copy of Certificate Authorities (CAs)
#!/bin/bash
# Download CA Certs (.crt) from a URL
# example: http://www.banxico.org.mx/servicios/certificados-ies-firma-electr.html
# Then check which certificates are valid and bundle them to a pem file
WEB_URL=http://www.banxico.org.mx/servicios/certificados-ies-firma-electr.html
SSL_CERT_DIR=ca
CA_BUNDLE=$SSL_CERT_DIR/ca-chain-bundle.pem
@idokd
idokd / cloudbuild.yaml
Last active October 10, 2019 12:41
Deploy a Github Wordpress Plugin to Wordpress.org subversion using Google Cloud Build triggers
steps:
- name: 'debian:stable-slim'
args: ['bash', './deploy-plugin.sh']
env:
- 'BUILD=$BUILD_ID'
- 'PROJECT=$PROJECT_ID'
- 'REV=$REVISION_ID'
- 'VERSION=$TAG_NAME'
- 'SVN_USERNAME=$_SVN_USERNAME'
- 'SVN_PASSWORD=$_SVN_PASSWORD'
@idokd
idokd / exportMySQLUsersPDO.php
Created January 17, 2021 12:40 — forked from zaiddabaeen/exportMySQLUsersPDO.php
Exports MySQL Users and Privileges using PDO
* Feel free to improve it.
* Original by Janich: https://gist.github.com/janich/6121771
*
* @requires PHP 5.3+
* @package ExportMySQLUsers
* @author Zaid Daba'een
* @license http://www.dbad-license.org/ DBAD license
*/
// Set up database root credentials
$host = 'localhost';
@idokd
idokd / init-plugin.php
Last active July 12, 2021 13:09
WordPress Initialization MU-Plugin (Must Use Plugin)
<?php
/**
* Plugin Name: Initialization Plugin
* Plugin URI: https://gist.github.com/idokd/224dec722a22b664c59e8d6ec221d997
* Description: Plugin to hook and define necessary functions before other all other plugins
* Version: 1.0.0
* Author: Ido Kobelkowsky
* Author URI: https://github.com/idokd
*/
@idokd
idokd / gravityforms-unique-id-sequence.php
Last active January 6, 2022 18:14
GravityForms Unique ID - Generates a alphanumeric, numeric, or sequential "Unique ID" for the entry when submitted
<?php
/*
- Add this to your functions.php
- Add a form input normal
- give it a gf-sequence class
*/
$gfex_gsf = false;
@idokd
idokd / strip-specific-tag-attribute.php
Last active September 10, 2021 08:02
Strip Specific HTML/XML tag attributes
<?php
// Based and altered from https://www.py4u.net/discuss/24287
function strip_tag_attributes( $html, $tag, $attr ) {
$domd = new DOMDocument();
libxml_use_internal_errors( true );
$domd->loadXML( $html );
libxml_use_internal_errors( false) ;
$domx = new DOMXPath( $domd );
$items = $domx->query('//' . $tag . '[@' . $attr . ']');
@idokd
idokd / wp-rocket-cache-gcp-cloud-cdn-invalidation.php
Last active September 19, 2021 09:20
WP Rocket Cache Purge / Invalidation with GCP Cloud CDN - Load Balancer
<?php
// Make sure that you have gcloud installed on server, and is accesible with the proper permissions to httpd/apache/ngix
// Update this variable with the GCP Cloud CDN Load Balancer name, or set it via filter: gcp_cloud_cdn_urlmap
define( 'GCP_CLOUD_CDN_URLMAP', 'your-load-balancer-id-goes-here' );
add_action( 'after_rocket_clean_home', 'gcp_cloud_cdn_invalidate_cdn_cache_home', 100 );
add_action( 'after_rocket_clean_domain', 'gcp_cloud_cdn_invalidate_cdn_cache_domain', 100 );
add_action( 'after_rocket_clean_cache_dir', 'gcp_cloud_cdn_invalidate_cdn_cache', 100 );
@idokd
idokd / mailgun-api-force-template.php
Created September 19, 2021 15:57
WordPress + Mailgun plugin - Apply Template to all WordPress mail
<?php
/*
This code with conjunction of Wordpress Mailgun plugin will force all wordpress mails to apply mailgun wordpress to all mail,
This could be easy way to beautify emails.
use {{subject}} {{text}} or {{{html}}} - see that html has triple {{{ in order to use raw content and not escape special chars
*/
add_filter( 'mg_mutate_message_body', function( $body ) {
@idokd
idokd / readable-strings.php
Created October 31, 2021 13:42
un-obfuscation
<?php
if ( !function_exists( 'str_ends_with' ) ) {
function str_ends_with( $str, $end ) {
return( @substr_compare( $str, $end, -strlen( $end ) ) == 0 );
}
}
function mocleanr( $filename, $replace = false ) {
if ( !is_dir( $filename ) ) {