Skip to content

Instantly share code, notes, and snippets.

View dead23angel's full-sized avatar

David Ange dead23angel

View GitHub Profile
@dead23angel
dead23angel / gist:7b3b4e2d1bb33015159efd02a2aeb1c6
Created April 2, 2022 09:27 — forked from timohausmann/gist:5003280
Javascript Math: get the distance between two points.
/**
* return the distance between two points.
*
* @param {number} x1 x position of first point
* @param {number} y1 y position of first point
* @param {number} x2 x position of second point
* @param {number} y2 y position of second point
* @return {number} distance between given points
*/
Math.getDistance = function( x1, y1, x2, y2 ) {
function calculate_age($birthday) {
$birthday_timestamp = strtotime($birthday);
$age = date('Y') - date('Y', $birthday_timestamp);
if (date('md', $birthday_timestamp) > date('md')) {
$age--;
}
return $age;
}
//вызов функции

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting & zsh-artisan)

  • Download zsh-autosuggestions by
encodeQueryFromArgs: function(args) {
console.log(args);
var result="?", counter = 1;
// create enconded URL from args
for (var key in args) {
var keyValue = "";
if ( args[key] instanceof Array ) {
/*
* We are dealing with an array in the query string ?key=Value0&key=Value1
@dead23angel
dead23angel / helpers.php
Created September 14, 2016 02:07 — forked from Ellrion/helpers.php
Showing all database queries in Laravel 5.2+
<?php
if (! function_exists('dbd')) {
/**
* Showing all database queries.
* Отображение всех запросов в базу.
*
* @param null|\Illuminate\Console\Command|\Psr\Log\LoggerInterface $channel
*/
function dbd($channel = null)
@dead23angel
dead23angel / helpers.php
Created February 10, 2016 15:49 — forked from Ellrion/helpers.php
extended laravel escaping with exclusion some tags
<?php
/**
* use in blade template `{!! ex($message, ['br', 'strong']) !!}`
*/
if (!function_exists('ex')) {
function ex($str, array $excluded)
{
$patterns = $tags = [];
foreach ($excluded as $ex) {
$open_tag = '<' . $ex . '>';
@dead23angel
dead23angel / artisan.php
Created February 1, 2016 15:56 — forked from vkbansal/artisan.php
Tying to use artisan migrate commands outside laravel
<?php
require_once "vendor/autoload.php";
use Symfony\Component\Console\Application;
use Illuminate\Database\Console\Migrations;
use Pimple\Container;
$container = new Container();
$container['migration-table'] = 'migration';
# Редиректы
rewrite "^/page/([0-9]+)(/?)$" /index.php?cstart=$1 last;
# Сам пост
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6&seourl=$6 last;
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5&seourl=$5 last;
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$" /engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5&seourl=$5 last;
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$" /index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4&seourl=$4 last;
rewrite "^/([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$" /index.php?newsid=$4&news_page=$2&cstart=$3&seourl=$5&seocat=$1 last;
rewrite ^/page/(.*)$ /index.php?cstart=$1 last;
location / {
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/*$" /index.php?year=$1&month=$2&day=$3 last;
rewrite "^/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)/*$" /index.php?year=$1&month=$2&day=$3&cstart=$4 last;
rewrite "^/([0-9]{4})/([0-9]{2})/*$" /index.php?year=$1&month=$2 last;
rewrite "^/([0-9]{4})/([0-9]{2})/page/([0-9]+)/*$" /index.php?year=$1&month=$2&cstart=$3 last;
rewrite "^/([0-9]{4})/*$" /index.php?year=$1 last;
rewrite "^/([0-9]{4})/page/([0-9]+)/*$" /index.php?year=$1&cstart=$2 last;
rewrite "^/([^.]+)/page/([0-9]+)/*$" /index.php?do=cat&category=$1&cstart=$2 last;
server {
listen 80;
server_name coderweb.ru;
access_log /var/www/coderweb.ru/logs/access.log;
error_log /var/www/coderweb.ru/logs/error.log;
location / {
uwsgi_pass unix:///var/tmp/coderweb.ru.sock;
include uwsgi_params;
}