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 / bootstrap4-media-breakpoints.css
Last active February 23, 2024 14:20 — forked from withArtur/bootstrap4-media-breakpoints.css
Bootstrap 4 all media query breakpoints (xs,sm,md,lg,xl) up to, down from, only
/**
* 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
*/
@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 / .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 / instagram_api.php
Created June 15, 2016 12:52
Instagram API retrive access token with PHP curl
<?php
// yo can follow this guide to http://www.benrlodge.com/blog/post/how-to-generate-an-instagram-access-token#
#1 first you need to create a Client in Instgram Developer Dashboard
// https://www.instagram.com/developer/clients/manage/
#2 after you need to retrive a oAuth code for after get access_token
// https://www.instagram.com/developer/authentication/
// change the params with your one and open link in browser
<?php
$gallery_loop = false;
$the_content = get_the_content(); // all content
$galleries = []; //Create empty figures array that will hold all of our parsed HTML data
while ($gallery_loop) {
$gallery = $the_content; // <figure .. </figure>
//<!-- wp:gallery {"ids":[742,739,737],"linkTo":"none"} -->
$cut_from = '<!-- wp:gallery';
@arturmamedov
arturmamedov / simple-entire-request-cache.php
Last active April 13, 2021 14:30
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)
<?php
$url = $_SERVER["REQUEST_URI"];
// clear all cache
if ($url == '/cache/clear-all') {
array_map('unlink', glob("cache/*.html"));
exit('Cache clear successfully!');
}
/**
* 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 / w-global-tools.js
Last active July 28, 2020 07:16
Tools that change global behavior of website things, for not deal with a lot of changes for a little thing
/**
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 / 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 / withAlert.js
Last active July 9, 2019 16:33
Show bootstrap 3/4 alerts like notifications or whatever you want simply by call `withAlert('message', 'type')`
/**
* withAlert()
*
* @dependencies [css: bootstrap(.alert), withstyle(.withAlert), jquery]
*
* @param string message
* @param string type warning|success|danger|primary|secondary|info
* @param object options {autohide: true/false, hidetime: 6000, placement: top|bottom}
*/
function withAlert(message, type, options) {