Skip to content

Instantly share code, notes, and snippets.

View arturmamedov's full-sized avatar
💭
Sul pezzo

Artur arturmamedov

💭
Sul pezzo
View GitHub Profile
@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]
@arturmamedov
arturmamedov / to-top.html
Created November 22, 2016 09:50
To top JS and HTML
<!-- 1 -->
<a href="#" id="totop">TOP</a>
<script>
if ($('#totop').length) {
var scrollTrigger = 100, // px
backToTop = function () {
var scrollTop = $(window).scrollTop();
if (scrollTop > scrollTrigger) {
$('#totop').addClass('show');
} else {
@arturmamedov
arturmamedov / css_cursor_table
Created September 9, 2016 12:49
CSS cursor values Table
<table class="data myne_kol" style="width:450px">
<caption>
Tabella dei Cursori CSS
</caption>
<tbody><tr>
<th>Cursore</th>
<th>Valore CSS</th>
<th>Esempio</th>
</tr>