Skip to content

Instantly share code, notes, and snippets.

View enix-app's full-sized avatar
🎯
Focusing

E enix-app

🎯
Focusing
  • EnixApp
View GitHub Profile
@enix-app
enix-app / gist:a8370aa562387717b81e6c92eac79cb0
Created September 14, 2020 09:20 — forked from stewartduffy/gist:481f21ea4906e611d934
Regex to remove file extension from JS string.
var filenameFull = "tm_icons.png";
//Regex to remove
var filenameText = filenameFull.replace(/\.[^/.]+$/, "");
@enix-app
enix-app / .router.php
Last active September 20, 2020 10:34
An alternative router.php
<?php
define('__SELF__', getcwd());
if (preg_match('/\.(?:png|jpg|jpeg|gif|js|css|html)$/', $_SERVER["REQUEST_URI"])) {
$ext = pathinfo($_SERVER["REQUEST_URI"])['extension'];
$extensions = [
'js' => 'text/javascript',
'css' => 'text/css',
@enix-app
enix-app / kotoblog_parse-http-accept-language-header.php
Created September 21, 2020 06:35 — forked from spolischook/kotoblog_parse-http-accept-language-header.php
Get prefer language by parsing HTTP_ACCEPT_LANGUAGE header
<?php
$prefLocales = array_reduce(
explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']),
function ($res, $el) {
list($l, $q) = array_merge(explode(';q=', $el), [1]);
$res[$l] = (float) $q;
return $res;
}, []);
arsort($prefLocales);
@enix-app
enix-app / clear-cache.js
Created September 22, 2020 02:51 — forked from deanhume/clear-cache.js
Clear Service Worker Cache
if ('serviceWorker' in navigator) {
caches.keys().then(function(cacheNames) {
cacheNames.forEach(function(cacheName) {
caches.delete(cacheName);
});
});
}
@enix-app
enix-app / paginationsequence.php
Created February 2, 2023 16:01 — forked from bramus/paginationsequence.php
Pagination Sequence Generator
<?php
/**
* Generate a sequence of numbers for use in a pagination system, the clever way.
* @author Bramus Van Damme <bramus@bram.us>
*
* The algorithm always returns the same amount of items in the sequence,
* indepdendent of the position of the current page.
*
* Example rows generated: