Skip to content

Instantly share code, notes, and snippets.

View fdcore's full-sized avatar
🦄
Работаю круглосуточно

Dmitriy Nyashkin fdcore

🦄
Работаю круглосуточно
View GitHub Profile

Keybase proof

I hereby claim:

  • I am fdcore on github.
  • I am nyashkin (https://keybase.io/nyashkin) on keybase.
  • I have a public key ASA_th1q1SEqIGZDtAgr3Cr7ZcEdBTtx1QWrt7sjv3MCWQo

To claim this, I am signing this object:

<?php
$data = array(
[
'measurement' => 'time',
'tags' => [
"host" => 'server02',
],
'fields' => ['value' => mt_rand(1, 100)],
'timestamp' => exec('date +%s%N')
<?php
function redirect_no_referral($url)
{
echo '<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
@fdcore
fdcore / array_median.php
Created January 21, 2018 13:29
Высчитываение средней медианы
<?php
/*
Высчитываение средней медианы
@params array массив чисел
*/
function array_median($array) {
// perhaps all non numeric values should filtered out of $array here?
$iCount = count($array);
if ($iCount == 0) {
throw new Exception('Median of an empty array is undefined');
<div id="app">
<div>
<button @click="sort_by='name'">name</button>
<button @click="sort_by='price'">price</button>
<button @click="sort_by='count'">count</button>
</div>
<hr>
<div>
<button @click="by_desc=true">ASC</button>
@fdcore
fdcore / random_priority.php
Last active September 27, 2017 23:32
Функция случайности с приоритетом
<?php
/*
Функция случайности с приоритетом
@author Dmitriy Nyashkin
@param (array) arr - Array with priority key
@param (string) priority_key - Array key for use priority
@return array - single array
*/
function random_priority($arr, $priority_key = 'priority')
{
@fdcore
fdcore / is_mobile.js
Created August 31, 2017 20:08
Check is on mobile view
/*
#mobile_element {
display: none;
}
@media (max-width: 768px) {
#mobile_element {
display: block;
}
}
*/
function magic(code) {
return atob(code);
}
$(document).ready(function(){
var html = $('.content').html();
var match_list = html.match(/\[loli:([a-zA-Z0-9=]+)\]/gi);
$(match_list).each(function(index, item){
var img = magic(item.match(/\[loli:([a-zA-Z0-9=]+)\]/i)[1]);
/*
* make full center on screen
* author @nyashkin
* */
function to_center($el) {
$el.css('left', 'calc(50% - ' + $el.width() + 'px / 2)');
$el.css('top', 'calc(50% - ' + $el.height() + 'px / 2)');
}
<?php
class Example extends CI_Model
{
const TABLE = 'example';
private $CI = null;
private $data = [];
function __construct($id = null)