Skip to content

Instantly share code, notes, and snippets.

@icodus
icodus / custom-queries.php
Created October 8, 2020 12:30 — forked from carlodaniele/custom-queries.php
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@icodus
icodus / my_init_memory.php
Created September 10, 2020 19:30 — forked from strangerstudios/my_init_memory.php
Increase memory and execution time for WP admins only.
/*
Increase memory and execution time for WP admins
You can add code to your php.ini, .htaccess, or wp-config.php
to increase execution times and memory limits to get WordPress
and PMPro to work when it needs more memory, time, or both.
However, sometimes you only need the extra memory and time
when doing something an admin would be doing... like exporting
a members list or orders table.
<?php
/**
* Plugin Name: NGINX FastCGI cache purge
* Version: 0.1
* Description: Flush NGINX FastCGI cache purge
* Author: The Shipyard Crew
* Author URI: https://theshipyard.se/
* Plugin URI: https://theshipyard.se/
* Text Domain: nginx-fastcgi-cache-purge
@icodus
icodus / strong-passwords.php
Created July 31, 2020 14:26 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@icodus
icodus / cert-curl.php
Created July 27, 2020 17:42 — forked from nebulak/cert-curl.php
PHP curl request with ssl/tls client certificate
<?php
//source: http://www.zedwood.com/article/php-curl-connect-with-ssl-client-certificate
class SecureRequest
{
private m_publicCertPath; //"/public_cert.pem"
private m_privateCertPath; //"/private.pem")
private m_caInfoPAth; //"/etc/ssl/certs/ca-certificates.crt"
public function init($publicCertPath, $privateCertPath, $caInfoPath) {
$this->m_publicCertPath = $publicCertPAth;
@icodus
icodus / curl.sh
Created June 9, 2020 22:02 — forked from JPry/curl.sh
Use CURL to request a domain name/path from a specific IP address. Substitute the domain for "example.com", and the IP address and path in the URL.
curl -H "Host: example.com" -I http://IP.ADD.RE.SS/path/to/file/or/folder/
@icodus
icodus / clone-mysql-db.sh
Last active June 12, 2019 21:42 — forked from christopher-hopper/clone-mysql-db.sh
Clone a MySQL database to a new database on the same server without using a dump file. This is much faster than using mysqldump.
#!/bin/bash
DBUSER="root";
DBPASS="";
DBHOST="localhost";
DB_OLD=mydatabase
DB_NEW=clone_mydatabase
DBCONN="--host=${DBHOST} --user=${DBUSER} --password=${DBPASS}";
@icodus
icodus / main.go
Created March 21, 2019 02:22 — forked from mschoebel/main.go
Snippet: login/logout (Golang)
package main
import (
"fmt"
"github.com/gorilla/mux"
"github.com/gorilla/securecookie"
"net/http"
)
// cookie handling
@icodus
icodus / purge-multi.lua
Created July 25, 2018 08:34 — forked from titpetric/purge-multi.lua
Delete NGINX cached items with a PURGE with wildcard support
-- Tit Petric, Monotek d.o.o., Tue 03 Jan 2017 06:54:56 PM CET
--
-- Delete nginx cached assets with a PURGE request against an endpoint
-- supports extended regular expression PURGE requests (/upload/.*)
--
function file_exists(name)
local f = io.open(name, "r")
if f~=nil then io.close(f) return true else return false end
end
@icodus
icodus / purge.lua
Created July 25, 2018 08:34 — forked from Jijun/purge.lua
Delete NGINX cached items from a PURGE request
-- Tit Petric, Monotek d.o.o., Thu 27 Oct 2016 10:43:38 AM CEST
--
-- Delete nginx cached assets with a PURGE request against an endpoint
--
local md5 = ngx.md5
function file_exists(name)
local f = io.open(name, "r")
if f~=nil then io.close(f) return true else return false end