Skip to content

Instantly share code, notes, and snippets.

@kezenwa
kezenwa / Query
Created February 22, 2021 04:33 — forked from lukecav/Query
MySQL script to get all WooCommerce orders including metadata
select
p.ID as order_id,
p.post_date,
max( CASE WHEN pm.meta_key = '_billing_email' and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email,
max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_first_name,
max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_last_name,
max( CASE WHEN pm.meta_key = '_billing_address_1' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_1,
max( CASE WHEN pm.meta_key = '_billing_address_2' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_2,
max( CASE WHEN pm.meta_key = '_billing_city' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_city,
max( CASE WHEN pm.meta_key = '_billing_state' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_state,
/*jslint continue:true*/
/**
* Adapted from {@link http://www.bulgaria-web-developers.com/projects/javascript/serialize/}
* Changes:
* Ensures proper URL encoding of name as well as value
* Preserves element order
* XHTML and JSLint-friendly
* Disallows disabled form elements and reset buttons as per HTML4 [successful controls]{@link http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2}
* (as used in jQuery). Note: This does not serialize <object>
* elements (even those without a declare attribute) or
@kezenwa
kezenwa / Cookies.js
Created November 6, 2021 22:15 — forked from fercarvo/Cookies.js
Pure Javascript Cookies Management
class Cookies {
static get (name) {
if (document.cookie.length === 0)
return null;
var c_start = document.cookie.indexOf(`${name}=`);
if (c_start === -1)
return null;
c_start = c_start + name.length + 1;
@kezenwa
kezenwa / optimag.sh
Created April 19, 2022 14:41 — forked from TomaszGasior/optimag.sh
Optimize JPEG, PNG and SVG images with one simple command.
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
get_file_mime_type()
{
local filename=$1
file -b --mime-type "$filename"
}
@kezenwa
kezenwa / Why WhatsApp Will Never Be Secure.md
Created July 8, 2022 18:22
Why WhatsApp Will Never Be Secure
@kezenwa
kezenwa / ampify.php
Created October 3, 2022 06:26 — forked from adactio/ampify.php
Make a chunk of markup AMP-ready
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
function ampify($html='') {
# Replace img, audio, and video elements with amp custom elements
$html = str_ireplace(
['<img','<video','/video>','<audio','/audio>'],
@kezenwa
kezenwa / amp-converter.php
Created October 3, 2022 06:27 — forked from williankeller/amp-converter.php
Convert HTML to AMP
<?php
class AMP {
private $html;
/**
* HtmlToAmp constructor.
*/
public function __construct($htmlContent) {
@kezenwa
kezenwa / ftp-backup.pl
Created April 3, 2023 05:50 — forked from ZEROF/ftp-backup.pl
FTP Perl backup script for Debian 7
#!/usr/bin/perl -w
# ORGINAL FTP BACKUP SCRIPT V1.00
# Version 1.01 2nd hand coded BY ZEROF <zerof at backbox.org>
# This script was updated because some providers support only FTP passive mode (like online.net)
# And I needed Debian support as well (replaced path of gzip)
# SFTP support didn't work, need few lines of new code I guess, I didn't spend to much time on that part
# i just disabled, for now. If you have idea about fixing this, keep me posted.
# Is this best solution you will find? Nop, find some more secured scipt like duplicity
# COPYRIGHT 2013 - WEBHOSTINGHERO.COM
@kezenwa
kezenwa / cpuUsageInPercent.sh
Created May 3, 2023 19:23 — forked from egulhan/cpuUsageInPercent.sh
How to get CPU usage in percent on Linux
top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}'
@kezenwa
kezenwa / mime-types.php
Created May 3, 2023 19:24 — forked from egulhan/mime-types.php
Learn mime-types from extension name and vice-versa in PHP
<?php
/*
* @source http://stackoverflow.com/questions/1147931/how-do-i-determine-the-extensions-associated-with-a-mime-type-in-php
*/
function system_extension_mime_types() {
# Returns the system MIME type mapping of extensions to MIME types, as defined in /etc/mime.types.
$out = array();
$file = fopen('/etc/mime.types', 'r');