Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Sul pezzo

Artur arturmamedov

💭
Sul pezzo
View GitHub Profile
@arturmamedov
arturmamedov / simple-entire-request-cache.php
Last active Apr 13, 2021
Create a entire request cache file and serve it instead of exucete all code each time (also in my CMS i add an webhook/event that open url /cache/clear-all for clear all cache when i update data)
View simple-entire-request-cache.php
<?php
$url = $_SERVER["REQUEST_URI"];
// clear all cache
if ($url == '/cache/clear-all') {
array_map('unlink', glob("cache/*.html"));
exit('Cache clear successfully!');
}
@arturmamedov
arturmamedov / w-global-tools.js
Last active Jul 28, 2020
Tools that change global behavior of website things, for not deal with a lot of changes for a little thing
View w-global-tools.js
/**
In example make all images of website content (maybe insterted trough editor)
openable trough gallery
[this work with Blueimp Gallery https://github.com/blueimp/Gallery]
*/
$(".auto-gallery-content").each(function(){
var data_gallery = $(this).data("autoGallery") ? $(this).data("autoGallery") : "gallery";
$("img", $(this)).each(function () {
if (!$(this).hasClass('no-auto-gallery')) {
@arturmamedov
arturmamedov / w-whatsapp.js
Created May 16, 2019
WhatsApp Api on Mobile and Desktop
View w-whatsapp.js
/**
* Replace mobile URL of WhatsApp with Desktop
* The mobile first strategy is used cause most people decide to not show WhatsApp on Desktop but only on mobile where it is very useful
*
* @dependencies [ core/w-ismobile.js ]
*/
if(withOptions.whatsappWeb && !jQuery.browser.mobile && $(".whatsapp-weburl").length > 0){
clog('WhatsApp Enabled and Present');
clog($(".whatsapp-weburl"));
@arturmamedov
arturmamedov / bootstrap4-media-breakpoints.css
Last active Jun 12, 2020 — forked from withArtur/bootstrap4-media-breakpoints.css
Bootstrap 4 all media query breakpoints (xs,sm,md,lg,xl) up to, down from, only
View bootstrap4-media-breakpoints.css
/**
* Bootstrap 4 all media queries #wMQ
* https://getbootstrap.com/docs/4.5/layout/overview/
* up > sm, md, lg, xl
* down < sm, md, lg
* only = xs, sm, lg, xl
* between <> sm-lg, sm-xl, md-xl
*/
View traffic_sources_cookies.js
/**
* You also can find
* Improved version and documentation
* on repository: https://github.com/arturmamedov/utm_referral-cookie
*/
// configuration
var $hostname = '.sviluppo1.loc',
cookie_params = ['source', 'medium', 'campaign']; // there are also [... 'term', 'content'] !commented
@arturmamedov
arturmamedov / ga_referrer-analytics.js
Created Jan 30, 2019
Google Analytics (analytics.js) get referral `ga_referrer`
View ga_referrer-analytics.js
ga(function(tracker) {
var ga_refferer = tracker.get('referrer'); // this get the referral from google analytics.js
if (typeof wCookies != 'undefined' && typeof wCookies().get('ga_refferer') == 'undefined') {
if (typeof ga_refferer != 'undefined') {
wCookies().set('ga_refferer', ga_refferer, {expires: 30});
} else {
wCookies().set('ga_refferer', 'direct', {expires: 30});
}
View detectmobilebrowser.js
/**
* jQuery.browser.mobile (http://detectmobilebrowser.com/)
*
* jQuery.browser.mobile will be true if the browser is a mobile device
*
**/
(function (a) {
(jQuery.browser = jQuery.browser || {}).mobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(
@arturmamedov
arturmamedov / standalonepopup.html
Last active Jul 24, 2018
elFinder standalonepopup in a new browser window (not modal, colorbox etc.)
View standalonepopup.html
<!-- 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 Feb 14, 2018
Select Eloqeunt models, filter it and transfrom for export in xls with custom format to
View laravel_db_to_excel.php
<?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);
View tips.blade.php
Instead of if and isset, directly isset Laravel v5.4
@isset($aVar)
// if (isset($aVar))
@else
// else
@endisset
Loops