Skip to content

Instantly share code, notes, and snippets.

View arturmamedov's full-sized avatar
💭
plan, learn, code, repeat

Artur arturmamedov

💭
plan, learn, code, repeat
View GitHub Profile
@arturmamedov
arturmamedov / standalonepopup.html
Last active May 10, 2023 08:25
elFinder standalonepopup in a new browser window (not modal, colorbox etc.)
<!-- main.html (html input and js for open new window with elFinder for select file) -->
<input type="text" class="form-control" value="" id="idOfInput" onfocus="return openElFinder(event, 'idOfInput');"/>
<script>
$( document ).ready(function() {
window.input_id = '';
window.openElFinder = function (event, input_id) {
event.preventDefault();
window.single = true;
@arturmamedov
arturmamedov / laravel_db_to_excel.php
Created February 14, 2018 08:57
Select Eloqeunt models, filter it and transfrom for export in xls with custom format to
<?php
// refer for this gist for first steps that are trhe same: https://gist.github.com/arturmamedov/0b2e5b7e39c7e1de8fc09f69f79db618
$parent_id = '1';
// select all children sites
$sites = Site::where('parent_id', $parent_id)->get();
//dd($sites);
$children_id = $sites->pluck('id');
//dd($children_id);
@arturmamedov
arturmamedov / tips.blade.php
Last active June 26, 2018 14:08
Blade tips
Instead of if and isset, directly isset Laravel v5.4
@isset($aVar)
// if (isset($aVar))
@else
// else
@endisset
Loops
@arturmamedov
arturmamedov / laravel_excel_to_db.php
Last active January 26, 2018 18:37
install `laravel`, install `maatwebsite/excel` and import data from excel to db table
<?php
// #1 - Install laravel: https://laravel.com/docs/5.5#installation
/* $console/bash/cmd commands >
$> composer global require "laravel/installer"
$> laravel new excel_to_db_project
$> cd excel_to_db_project
// #2 - Install excel package, documentation on: https://github.com/Maatwebsite/Laravel-Excel if laravel >5.5 no need to do nothing
$> composer require "maatwebsite/excel"
*/
@arturmamedov
arturmamedov / ResourcesTable.php
Created October 13, 2017 09:40
CakePHP - beforeFind() callback with default conditions and possibility to disable it
<?php
public function beforeFind($event, $query, $options, $primary)
{
// if query builder have ->applyOptions(['default' => false]) not use default conditions and return query
if (isset($options['default']) && $options['default'] == false) {
return $query;
}
// default conditions
@arturmamedov
arturmamedov / git-tag-delete-local-and-remote.sh
Created September 27, 2017 10:49 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@arturmamedov
arturmamedov / on_before_unload.js
Last active July 9, 2019 16:35
Window on before unload - for stop user to escape page before all data is not saved or an action not performed
// Message to be displayed on unload
var message = $('#jtrnslt #leavemess').text(), submitting = false;
// On Form submition set submitting to true for not fire onbeforeunload
$(document).on("submit", "form", function(event){
submitting = true;
});
// Window onbeforeunload fired when leave page but not if it a form submition or element with .noBeforeUnload class
window.onbeforeunload = function (e) {
e = e || window.event;
// Determine if you want to allow unload
@arturmamedov
arturmamedov / withEqualHeight.html
Last active February 3, 2017 11:39
Equl Height for elements
<script>
/**
* Boxes AutoHeight
*
* @param columns
*
* data-weh-add="50" add 50px to all
*/
function withEqualHeight(columns) {
var tallestcolumn = 0, add = parseInt(columns.first().attr('data-weh-add'));
@arturmamedov
arturmamedov / merge_options.php
Last active February 12, 2019 10:34
Merge $defaults with custom passed $options
<?php
/*
* spesso abbiamo bisogno di parametri default obbligatori
* ma che possono essere sovrascritti con quelli custom passati alla funzione ad ogni chiamata
* ... la suluzione in 4 righe e' questa
* ---
* [EN] often we need a mandatory options parameters that can be overriden by custom params passed each time
* the solution is here in 4 rows of code
*/
@arturmamedov
arturmamedov / .htaccess
Last active January 7, 2023 01:36
Rewrite Rules - must used
# 0 - Before any rule check for mod-rewrite module existance and enable it
<IfModule mod_rewrite.c>
# Enable before other rules
RewriteEngine On
</IfModule>
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]