Skip to content

Instantly share code, notes, and snippets.

Alex McOwkin AlexMcowkin

Block or report user

Report or block AlexMcowkin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AlexMcowkin
AlexMcowkin / random_time.js
Created Aug 14, 2018
javascript: get random time between today and yesterday
View random_time.js
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://momentjs.com/downloads/moment.js"></script>
<script>
$(document).ready(function() {
function getRandomMilisecond(min, max)
{
var randomMinute = Math.floor(Math.random() * (max - min + 1)) + min;
return randomMinute * 60000; // 1 min = 60000 mls
}
@AlexMcowkin
AlexMcowkin / not_unique.sql
Created Aug 8, 2018
SQL: выбор не уникальных (повторяющихся) значений из таблицы
View not_unique.sql
CREATE TABLE `post` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
//----------------------------------------
SELECT id, name FROM post WHERE id IN (SELECT id FROM post GROUP BY id having count(id) > 1) ORDER BY id;
@AlexMcowkin
AlexMcowkin / bracket_validation.php
Created Aug 7, 2018
Проверка строки на верное количество скобок на php
View bracket_validation.php
<?php
$string = 'This is (ok)';
function bracketValidation($string)
{
$counter = 0;
$openBracket = ['(','{','['];
$closedBracket = [')','}',']'];
@AlexMcowkin
AlexMcowkin / CommondataController.php
Created Jan 15, 2018
laravel 5.5: yajrabox datatables add html code
View CommondataController.php
<?php
namespace App\Http\Controllers\Backend;
use App\Http\Controllers\Controller;
use App\Model\Commondata;
use Illuminate\Http\Request;
use App\Http\Requests\CommondataRequest;
class CommondataController extends Controller
View gist:d0338b43e31e355a8d3b3134aeba4521
public static function boot()
{
parent::boot();
self::deleting(function($model) {
if($model->default == 1)
return false;
});
self::updated(function($model){
@AlexMcowkin
AlexMcowkin / index.php
Created Apr 26, 2017
yii2: check if email exists
View index.php
try {
// send email
}
catch (Swift_TransportException $e) {
// delete email
}
View yii2_search_sphinx.php
public function actionSearch()
{
// ---------SphinxSearch----------
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
$searchText = HtmlPurifier::process(Yii::$app->request->get('search'));
$searchText = trim($searchText);
$sphinxQuery = new Query();
$sphinxResult = $sphinxQuery->from('post_index')->match($searchText)->all();
@AlexMcowkin
AlexMcowkin / php_decrypt_encrypt.php
Created Aug 20, 2015
способ зашифровать/дешифровать данные БЕЗ md5
View php_decrypt_encrypt.php
$key = 'password to (en/de)crypt';
$string = ' string to be encrypted '; // данные для шифровки/дешифровки
/////////////// Шифрование //////////////////
$iv = mcrypt_create_iv(
mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC),
MCRYPT_DEV_URANDOM
);
$encrypted = base64_encode(
View foreffactory.php
<?php
include_once('simple_html_dom.php');
// %progdir%\modules\wget\bin\wget.exe -q --no-cache http://forexfactory.loc/forexfactory.php
define ("PATH_TO_FOLDER", "C:/Users/Vadim/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075/MQL5/Files/");
// define ("PATH_TO_FOLDER", "E:/openserver522/openserver/domains/forexfactory.loc/");
define ("CSV_FILE_NAME", "forexfactoryparce.csv");
if(!file_exists(PATH_TO_FOLDER.CSV_FILE_NAME))
View gist:9f93f8de3e6a9ff2afdd
<?php
include_once('simple_html_dom.php');
// %progdir%\modules\wget\bin\wget.exe -q --no-cache http://forexfactory.loc/forexfactory.php
define ("PATH_TO_FOLDER", "C:/Users/Vadim/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075/MQL5/Files/");
// define ("PATH_TO_FOLDER", "E:/openserver522/openserver/domains/forexfactory.loc/");
define ("CSV_FILE_NAME", "forexfactoryparce.csv");
if(!file_exists(PATH_TO_FOLDER.CSV_FILE_NAME))
You can’t perform that action at this time.