Skip to content

Instantly share code, notes, and snippets.

View AgelxNash's full-sized avatar
Open to suggestions

Евгений Борисов AgelxNash

Open to suggestions
View GitHub Profile
@ziadoz
ziadoz / ternary.php
Last active December 11, 2015 23:28
PHP Ternary (Left/Right Associative)
#!/usr/bin/env php
<?php
// Left associative ternary.
// Output: T
echo (true ? 'True' : false ? 'T' : 'F') . "\n";
// This is essentially the same as above.
// Output: T
echo ((true ? 'True' : false) ? 'T' : 'F') . "\n";
<?php
error_reporting(E_ALL);
class StringTypeHandler {
public function length() {
return strlen($this);
}
}
@ziadoz
ziadoz / index.html
Last active February 14, 2021 09:13
HTML5 Webcam / CSS3 Image Filter Experiment
<!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,
@artdevue
artdevue / gist:4345410
Created December 20, 2012 13:47
validEmail
<?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);
@Mark-H
Mark-H / a readme.md
Last active November 24, 2022 13:16
modCli; using MODX on the commandline.

modCLI

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.

Syntax

@Mark-H
Mark-H / benchmark.php
Created December 7, 2012 17:41
MODX Performance Benchmark Snippet
<?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;">';
@bladeofsteel
bladeofsteel / html.part.html
Created November 25, 2012 17:55
Элементарные социальные share-кнопки. see http://habrahabr.ru/post/156185/ & http://jsfiddle.net/rrZBR/1/
<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>​
@ziadoz
ziadoz / index.php
Created September 10, 2012 16:35
PHP and Apache Environment Configuration
<?php
define('ENV', getenv('ENV') !== false ? getenv('ENV') : 'development');
/* OR */
define('ENV', isset($_SERVER['ENV']) ? $_SERVER['ENV'] : 'development');
@ziadoz
ziadoz / bootstrap.php
Created August 25, 2012 03:38
PHP Settings Bootstrap
<?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');
@ziadoz
ziadoz / awesome-php.md
Last active May 8, 2025 07:37
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.