Skip to content

Instantly share code, notes, and snippets.

@volter9
volter9 / index.php
Created October 18, 2015 20:55 — forked from Petah/index.php
2-cms
<?php
$view = preg_replace('/[^a-z]/', '', $_SERVER['REQUEST_URI']) ?: 'index';
require __DIR__ . '/layout.php';
@volter9
volter9 / example.php
Last active April 30, 2019 21:24
Cool validation module
<?php
require 'validation.php';
/** An example, validate the given data with given rules */
$data = [
'username' => 'voteforpedro',
'password' => '123456',
'confirm' => '123456',
@volter9
volter9 / form-preview.js
Created January 24, 2015 18:58
First version of my Form-Preview plugin for jQuery
$(function () {
var view = $('#preview'),
elements = $('.preview-form form').find('select, input, textarea');
function preview (specific) {
if (view.hasClass('off')) {
return;
}
if ( !specific ) {
@volter9
volter9 / header.php
Created January 3, 2015 18:37
Handling scalar PHP type hinting
/**
* @link http://php.net/manual/en/language.oop5.typehinting.php#111411
*/
function optimized_strpos ($ErrLevel, $ErrMessage) {
if ($ErrLevel == E_RECOVERABLE_ERROR)
return strpos($ErrMessage, 'must be an instance of string, string')
|| strpos($ErrMessage, 'must be an instance of integer, integer')
|| strpos($ErrMessage, 'must be an instance of float, double')
|| strpos($ErrMessage, 'must be an instance of boolean, boolean')
|| strpos($ErrMessage, 'must be an instance of resource, resource');
@volter9
volter9 / MooQuery.js
Created November 13, 2014 23:31
Better than jQuery
var MooQuery = function (query) {
this.elements = Array.prototype.splice.call(document.querySelectorAll(query), 0);
};
MooQuery.prototype = {
constructor: MooQuery,
each: function (callback) {
this.elements.map(callback);
},
};
@volter9
volter9 / multidimensional.php
Last active August 29, 2015 14:04
Two functions to manipulate multi-dimensional arrays
<?php
/**
* Two functions to work with multidimensional arrays.
* md_get to get array value using key separated by '.'
* md_set to set array value using key separated by '.'
* Easy, huh?
*
* @author volter9
*/