<p><abbr title="Anakin Skywalker">AS</abbr>:
Master Norris, do you really parse HTML with regex?</p>
<p><abbr title="Chuck Norris">CN</abbr>:
Not anymore… I have already parsed it all.</p>
<?php | |
namespace WPSE; | |
/** Plugin Name: Google JSAPI test plugin */ | |
add_action( 'admin_enqueue_scripts', __NAMESPACE__.'\addScripts' ); | |
function addScripts() | |
{ | |
wp_enqueue_script( |
<?php | |
/** | |
* Copyright (c) 2008, David R. Nadeau, NadeauSoftware.com. | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* | |
* * Redistributions of source code must retain the above copyright |
.entry-content { | |
img { | |
box-sizing: border-box; | |
max-width: 100%; | |
height: auto; | |
border: 1px solid #ccc; | |
padding: 2px; | |
} |
line-height: ceil(@height * .666); // 20px (round up) | |
line-height: floor(@height * .666); // 19px (round down) | |
line-height: round(@height * .666); // 20px (round to closest integer) | |
line-height: round(@height * .666, 1); // 20.0px (round to 1 decimal place) |
/** | |
* Shuffles array in place. | |
* @param {Array} a items The array containing the items. | |
*/ | |
function shuffle(a) { | |
var j, x, i; | |
for (i = a.length; i; i--) { | |
j = Math.floor(Math.random() * i); | |
x = a[i - 1]; | |
a[i - 1] = a[j]; |
Here’s how you can configure your Apache webserver for a REST API, without using rewrite rules (thus: you don’t need the rewrite engine). Simply add the following line to your <VirtualHost>
:
AliasMatch ^/api/rest/v1/(.*)$ /var/www/[mywebsite]/htdocs/api/rest/v1/index.php
In index.php
, you can read the parameters like so:
$path = preg_replace('~^/rest/v1/~', '', $_SERVER['SCRIPT_NAME']);
$parts = explode('/', $path);
var_dump($parts);
If asked the question, “What is the difference between UTF-8 and Unicode?”, would you confidently reply with a short and precise answer? In these days of internationalization all developers should be able to do that. I suspect many of us do not understand these concepts as well as we should. If you feel you belong to this group, you should read this ultra short introduction to character sets and encodings.
Actually, comparing UTF-8 and Unicode is like comparing apples and oranges:
UTF-8 is an encoding - Unicode is a character set
A character set is a list of characters with unique numbers (these numbers are sometimes referred to as “code points”). For example, in the Unicode character set, the number for A is 41.
An encoding on the other hand, is an algorithm that translates a list of numbers to binary so it can be stored on disk. For example UTF-8 would translate the number sequence 1, 2, 3, 4 like this:
<?php | |
/* | |
Copyright (c) 2012, Manu Manjunath | |
All rights reserved. | |
Redistribution and use of this program in source/binary forms, with or without modification are permitted. | |
Link to this gist is preferred, but not a condition for redistribution/use. | |
*/ | |
function mail_with_attachments($to, $subject, $message, Array $filepaths, $from = null, $replyto = null) { |
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i; | |
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){ | |
if (index > 0 && index + match.length !== title.length && | |
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" && | |
(title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') && | |
title.charAt(index - 1).search(/[^\s-]/) < 0) { | |
return match.toLowerCase(); | |
} |