Skip to content

Instantly share code, notes, and snippets.

View PierreLebedel's full-sized avatar

Pierre Lebedel PierreLebedel

View GitHub Profile
@paulsheldrake
paulsheldrake / Country codes
Created May 14, 2020 18:02
jVectormap World Map with all countries
AF : Afghanistan
AX : Aland Islands
AL : Albania
DZ : Algeria
AS : American Samoa
AD : Andorra
AO : Angola
AI : Anguilla
AG : Antigua and Barbuda
AR : Argentina
@mustafauysal
mustafauysal / non-namespaced-route.php
Created June 20, 2017 10:39
non-namespaced route for WP REST API
<?php
add_action( 'rest_api_init', function ( $server ) {
$server->register_route( 'foo', '/foo', array(
'methods' => 'GET',
'callback' => function () {
return 'baz';
},
) );
} );
@tresf
tresf / usb-scale.html
Last active February 8, 2022 03:17
Read weight from a USB scale
<html>
<!--
Author: A. Tres Finocchiaro, tres.finocchiaro@gmail.com
License: LGPL 2.1
Depends: QZ Tray 2.0.0-alpha1+
-->
<!-- Note: jquery is not needed in alpha2 -->
<script type="text/javascript" src="js/dependencies/jquery-1.11.3.min.js"></script>
<!-- Note: rsvp can be overriden via qz.setPromiseType(...) TODO: Get usage from @bberenz -->
<script type="text/javascript" src="js/dependencies/rsvp-3.1.0.min.js"></script>
@andreyserdjuk
andreyserdjuk / determine_csv_delimiter.php
Last active July 26, 2017 10:59
determine csv delimiter php
<?php
/**
* Determine csv delimiter
*
* @param resource $fileHandle - handle of csv file
* @return string - correct delimiter of csv file
*/
function determineCsvDelimiter($fileHandle)
{
@james2doyle
james2doyle / slugify.php
Last active January 12, 2022 13:19
Simple slugify function for PHP. Creates a slug for the passed string, taking into account international characters as well.
<?php
function slugify($string, $replace = array(), $delimiter = '-') {
// https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Utils/Slug.php
if (!extension_loaded('iconv')) {
throw new Exception('iconv module not loaded');
}
// Save the old locale and set the new locale to UTF-8
$oldLocale = setlocale(LC_ALL, '0');
setlocale(LC_ALL, 'en_US.UTF-8');
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
@samhernandez
samhernandez / customroutes.php
Last active October 10, 2023 10:11
A simple class to add custom routes to Wordpress.
<?php
/**
* NOTE: This gist is very old. You might want to check out recent forks
* like this one: https://github.com/Alexlytle/Wordpress_custom_route/blob/main/Wordpress_Custom_route.php
* (thanks @Alexlytle) If you have an improvement to this gist, please
* post a link in a comment for others who might benefit. Thanks!
*
* A class to create simple custom routes.
*