Skip to content

Instantly share code, notes, and snippets.

View jwv's full-sized avatar

Jonathan Vicente jwv

View GitHub Profile
@jwv
jwv / wp_list_table.php
Created May 10, 2022 09:43 — forked from donaldallen/wp_list_table
WP_List_Table example.
<?php
if ( ! class_exists('WP_List_Table')) {
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
class Events_List_Table extends WP_List_Table
{
function __construct()
{
global $status, $page;
@jwv
jwv / slugify.php
Created July 31, 2021 11:48
Slugify String
// https://www.php.net/manual/en/transliterator.transliterate.php
function slugify($string, $separator = '-')
{
$slug = trim(strip_tags($string));
$slug = transliterator_transliterate('NFD; [:Nonspacing Mark:] Remove; NFC; Any-Latin; Latin-ASCII; Lower();', $slug);
$slug = preg_replace("/[^a-zA-Z0-9\\/_|+ -]/", '', $slug);
$slug = preg_replace("/[\\/_|+ -]+/", $separator, $slug);
$slug = trim($slug, $separator);
return $slug;
}
@jwv
jwv / certbot-manual-dns.sh
Last active November 13, 2020 11:42
Certbot Manual DNS
# Method 1
certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory --manual-public-ip-logging-ok -d '*.<ypurdomain>' -d '<ypurdomain>'
# Method 2
certbot -d example.com --manual --preferred-challenges dns certonly
# Keyboard
defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)
@jwv
jwv / create-ssl-cert.bat
Last active September 21, 2018 22:44
CMD - Create SSL Cert NGINX
@ECHO OFF
ECHO Creating SSL Cert...
set NGINX_HOME=C:\nginx114
set OPENSSL_HOME="C:\Program Files\OpenSSL-Win64\bin"
set PATH=%PHP_HOME%;%PATH%
openssl req -x509 -nodes -days 36500 -newkey rsa:4096 -keyout %NGINX_HOME%/ssl/%1.key -out %NGINX_HOME%/ssl/%1.crt
ECHO SSL Cert Created...
ECHO %NGINX_HOME%/conf/%1.key
ECHO %NGINX_HOME%/conf/%1.crt
const admin = require("admin");
function getFirebaseUser(req, res, next) {
console.log("Check if request is authorized with Firebase ID token");
if (
!req.headers.authorization ||
!req.headers.authorization.startsWith("Bearer ")
) {
console.error(
"No Firebase ID token was passed as a Bearer token in the Authorization header.",
@jwv
jwv / getRealIPAddr.php
Created September 2, 2014 02:02
Get Real IP
function getRealIPAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
@jwv
jwv / force_download_a_file.php
Created September 1, 2014 10:00
Force download any File
function force_download_a_file($dl_file)
{
if(is_file($dl_file))
{
if(ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
header('Expires: 0');
header('Pragma: public');
header('Cache-Control: private',false);
@jwv
jwv / simpleXml2Array.php
Created November 6, 2013 11:35
XML2Array
<?php
class simpleXml2Array
{
public $namespaces, $arr;
public function __construct( $xmlstring, $namespaces=null )
{
$xml = new simpleXmlIterator( $xmlstring, null );
$this->namespaces = is_null( $namespaces ) ? null : $xml->getNamespaces( true );