Smart stores for Riot (like flux, based on ideas from RiotControl)
Small (<1.5Kb) flux-like store container.
Make sure loot.js is included in your page after riot.js:
#!/bin/bash | |
######## | |
# Purpose :- To take a backup of MongoDB Collections and upload to AWS s3 | |
# Requirement :- Make Sure Collection.config file is present in /data/Backup/mongodb | |
# format for Collection.config is db|collection | |
# For example | |
# db1|collections1 |
<?php | |
// PHP PThreads issue 329 diagnostic script by John Wellesz | |
// Also a nice example of shared object management... | |
const ONEMUSEC = 1000000; | |
printf('file age: %d', time() - filemtime(__file__)); | |
echo PHP_EOL; |
CREATE TYPE address AS (country text, city text, zip varchar(6), street text, number text, building text); | |
CREATE TABLE users (id SERIAL PRIMARY KEY, email text, adresses address[]); | |
INSERT INTO users(email, adresses) VALUES('[email protected]', ARRAY[ROW('RU', 'Moscow', '123123', 'Lenina', '5', 'a')::address, ROW('RU', 'SPB', '123456', 'Gagarina', '102', '5')::address]); | |
SELECT * FROM users; |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta http-equiv="Content-Language" content="ja" /> | |
<meta http-equiv="Content-Style-Type" content="text/css" /> | |
<meta http-equiv="Content-Script-Type" content="text/javascript" /> | |
<title>aaencode - Encode any JavaScript program to Japanese style emoticons (^_^)</title> |
<?php | |
function resizeImage($source, $dest, $new_width, $new_height, $quality) | |
{ | |
// Taken from http://salman-w.blogspot.com/2009/04/crop-to-fit-image-using-aspphp.html | |
$image = new Phalcon\Image\Adapter\GD($source); | |
$source_height = $image->getHeight(); | |
$source_width = $image->getWidth(); | |
$source_aspect_ratio = $source_width / $source_height; | |
$desired_aspect_ratio = $new_width / $new_height; | |
if ($source_aspect_ratio > $desired_aspect_ratio) { |
<?php | |
$router = new \Phalcon\Mvc\Router(false); | |
$router->removeExtraSlashes(true); | |
$router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI); | |
$api = new \Phalcon\Mvc\Router\Group(); | |
$api->setPrefix('/api/1'); | |
$api->addOptions('/{controller}', array('action' => 'options', 'namespace' => 'Api\V1')); |
<?php | |
class Url extends \Phalcon\Mvc\Url | |
{ | |
/** | |
* Generates a URL with GET params | |
* | |
* <code> | |
* |
/** | |
* @return mixed or false | |
*/ | |
function array_find($array, $fn) { | |
$next = current($array); | |
while ($next) { | |
$key = key($array); | |
if (call_user_func_array($fn, [$next, $key])) { | |
return $next; | |
} |
<?php | |
/** | |
* Определение наличия мата (нецензурных слов) в тексте, матотест | |
* | |
* Алгоритм достаточно надёжен и быстр, в т.ч. на больших объёмах данных | |
* Метод обнаружения мата основывается на корнях и предлогах русского языка, а не на словаре | |
* Слова "лох", "хер", "залупа", "сука" матерными словами не считаются (см. словарь Даля) | |
* Разработка ведётся с 2005 года | |
* | |
* Класс явл. хорошим учебным пособием по изучению регулярных выражений и... русского мата! =) |