Skip to content

Instantly share code, notes, and snippets.

View fenric's full-sized avatar
🇺🇦

Anatoly Nekhay fenric

🇺🇦
View GitHub Profile
.grid {
margin-left: -10px;
margin-right: -10px;
}
.grid:after {
content: "";
display: table;
clear: both;
}
.grid .column-1 {
var column = 1, gridSize = 12, dump = '';
for (; column <= gridSize; column++)
{
dump += "\n.grid .column-" + column + " {\n\twidth: " + parseFloat(column / gridSize * 100).toFixed(5) + "%;\n}";
}
console.log(dump);
<?php
function slug($rawString)
{
$stringSluggable = $rawString;
$stringSluggable = transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $stringSluggable);
$stringSluggable = preg_replace(['/[^a-z0-9-]/', '/-+/'], '-', $stringSluggable);
<?php
function is($location)
{
$uri = $_SERVER['REQUEST_URI'];
$path = parse_url($uri, PHP_URL_PATH);
$sanitized = addcslashes($location, '\.+?[^]${}=!|:-#');
<?php
function asset($location)
{
if (file_exists($filename = $_SERVER['DOCUMENT_ROOT'] . $location))
{
return sprintf('%s?revision=%s', $location, filemtime($filename));
}
return $location;
<?php
$email = 'test@mail.ru';
function valid_email($email)
{
if (filter_var($email, FILTER_VALIDATE_EMAIL))
{
list($user, $host) = explode('@', $email, 2);
@fenric
fenric / put-upload.php
Last active April 11, 2016 19:40
PHP file upload via PUT verb
<?php
if (strcmp($_SERVER['REQUEST_METHOD'], 'PUT') !== 0)
{
http_response_code(400);
exit(0);
}
$mimes = [
@fenric
fenric / put-upload.html
Last active April 11, 2016 16:17
JS file upload via PUT verb
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form>
<fieldset>
<legend>File:</legend>
<input type="file" required="true" title="Please, select file in your PC." />