Skip to content

Instantly share code, notes, and snippets.

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

Dmitriy Nyashkin fdcore

🦄
Работаю круглосуточно
View GitHub Profile
@fdcore
fdcore / random.php
Last active February 12, 2018 14:22
<?php
/*
$id (int) номер игры / ни на что не влияет
$min (int) минимальное значение рандома
$max (int) максимальное
$api (uuid) апи ключ
@return (array) массив данных ответа
*/
@fdcore
fdcore / noselect.css
Created December 11, 2016 18:15
Disable text selection highlighting using CSS
/* http://stackoverflow.com/a/4407335/3479278 */
.noselect {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
not supported by any browser */
@fdcore
fdcore / Token.php
Created December 13, 2016 00:57
Класс для работы с временными токенами на CodeIgniter + Sparrow
<?php
/*
Класс работы с токенами подтверждений данных
@author [email protected]
CREATE TABLE `confirm_data` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`token` varchar(32) NOT NULL,
`expire_time` int(11) NOT NULL,
@fdcore
fdcore / pseudo_random_array.php
Created January 21, 2017 19:31
Функция для псевдослучайного перемешивания массива, используя семя случайностей
<?php
/*
@param array массив для перемешивания
@param int семя случайных чисел
*/
function seededShuffle(array &$array, $seed) {
mt_srand($seed);
$size = count($array);
for ($i = 0; $i < $size; ++$i) {
list($chunk) = array_splice($array, mt_rand(0, $size-1), 1);
@fdcore
fdcore / toHHMMSS.js
Created March 18, 2017 00:28
JavaScript seconds to time string with format hh:mm:ss http://stackoverflow.com/a/6313008
String.prototype.toHHMMSS = function () {
var sec_num = parseInt(this, 10); // don't forget the second param
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
return hours+':'+minutes+':'+seconds;
@fdcore
fdcore / center.css
Created March 27, 2017 19:46
full center modal
.outer {
position: fixed;
top: calc(50% - 300px / 2);
background: red;
width: 300px;
display: flex;
height: 300px;
left: calc(50% - 300px / 2);
z-index: 10;
vertical-align: middle;
@fdcore
fdcore / random.php
Created April 5, 2017 13:38
random chance
<?php
// @param $c int шанс выйгрыша
function _randc($c){
mt_srand(crc32(microtime()));
return (mt_rand(0, 100) < $c);
}
// test avg random
function random_c($c=50){
$win = 0; $fail = 0;
<?php
class Example extends CI_Model
{
const TABLE = 'example';
private $CI = null;
private $data = [];
function __construct($id = null)
/*
* 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)');
}
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]);