Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
/* | |
Sape.RU Context Plugin for MODx Evolution | |
*/ | |
if (!defined('_SAPE_USER')){ | |
define('_SAPE_USER', ' _USER_FOLDER_ '); | |
} | |
require_once($_SERVER['DOCUMENT_ROOT'].'/'._SAPE_USER.'/sape.php'); | |
$sape_context = new SAPE_context(); |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
<?php | |
// Mode. | |
define('MODE', isset($_SERVER['MODE']) ? $_SERVER['MODE'] : 'development'); | |
// Character Set. | |
ini_set('default_charset', 'UTF-8'); | |
mb_internal_encoding('UTF-8'); | |
mb_regex_encoding('UTF-8'); | |
mb_http_input('UTF-8'); | |
mb_http_output('UTF-8'); |
<?php | |
define('ENV', getenv('ENV') !== false ? getenv('ENV') : 'development'); | |
/* OR */ | |
define('ENV', isset($_SERVER['ENV']) ? $_SERVER['ENV'] : 'development'); |
<a href="http://vk.com/share.php?url=URL&title=TITLE&description=DESC&image=IMG_PATH&noparse=true" target="_blank" onclick="return Share.me(this);"> {шарь меня правильно}</a> | |
<a href="http://www.facebook.com/sharer/sharer.php?s=100&p%5Btitle%5D=TITLE&p%5Bsummary%5D=DESC&p%5Burl%5D=URL&p%5Bimages%5D%5B0%5D=IMG_PATH" target="_blank" onclick="return Share.me(this);">{шарь меня правильно}</a> | |
<a href="http://connect.mail.ru/share?url=URL&title=TITLE&description=DESC&imageurl=IMG_PATH" target="_blank" onclick="return Share.me(this);">{шарь меня правильно}</a> | |
<a href="http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st.comments=DESC&st._surl=URL" target="_blank" onclick="return Share.me(this);">{шарь меня правильно}</a> | |
<a href="https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Ffiddle.jshell.net%2F_display%2F&text=TITLE&url=URL" target="_blank" onclick="return Share.me(this)">{шарь меня правильно}</a> |
<?php | |
// Use this line to prevent people from hammering your server. | |
if (!isset($_GET['super_secret']) || ($_GET['super_secret'] != 'secretpassword')) return 'Not authorized'; | |
// Call this snippet uncached in a resource with template "empty": | |
// content: "[[!benchmark]]" | |
// Make sure to tag the resource as uncachable | |
// The intro | |
echo '<body style="font-family: sans-serif;">'; |
modCLI is a wrapper for the MODX Revolution Processors, allowing you to pretty much do anything from the commandline that you would normally do within the manager.
To use modCLI, simply download the modcli.php file and put it in the MODX_BASE_PATH of your installation. Next open up the console or terminal, and start firing some commands at it.
<?php | |
function validEmail($email) { | |
$isValid = true; | |
$atIndex = strrpos($email, "@"); | |
if (is_bool($atIndex) && !$atIndex) { | |
$isValid = false; | |
} else { | |
$domain = substr($email, $atIndex+1); | |
$local = substr($email, 0, $atIndex); | |
$localLen = strlen($local); |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Image from Webcam</title> | |
<style type="text/css"> | |
video { display: block; margin: 0 auto; border: 10px solid #ccc; } | |
.button { margin: 10px auto; padding: 10px; background: #ccc; color: white; text-align: center; width: 200px; cursor: pointer; } | |
#container, |
<?php | |
error_reporting(E_ALL); | |
class StringTypeHandler { | |
public function length() { | |
return strlen($this); | |
} | |
} |