Skip to content

Instantly share code, notes, and snippets.

View joekolade's full-sized avatar

Joe Kolade joekolade

View GitHub Profile
@joekolade
joekolade / selfdestruction.js
Created April 8, 2023 14:13
[self destructing event listener]
let addSelfDestructingEventListener = (element, eventType, callback) => {
let handler = (e) => {
callback(e);
element.removeEventListener(eventType, handler);
};
element.addEventListener(eventType, handler);
};
@joekolade
joekolade / summertime.js
Created April 8, 2023 14:13
[Summertime detection JS]
/**
* @param d date
*/
function isDST(d) {
let jan = new Date(d.getFullYear(),0,1).getTimezoneOffset();
let jul = new Date(d.getFullYear(),6,1).getTimezoneOffset();
return Math.min(jan,jul) == d.getTimezoneOffset();
}
@joekolade
joekolade / replace.sql
Created April 8, 2023 14:12
[DB replace string]
UPDATE tt_content
SET bodytext = replace(bodytext, "a", "b");
@joekolade
joekolade / duplicates.sql
Created April 8, 2023 14:12
[DB Find duplicates in multiple fields]
SELECT c.uid as "CE uid", c.pid as "CE pid", uid_foreign, uid_local, count(*) as NumDuplicates
FROM sys_file_reference s
JOIN tt_content c ON (c.uid = s.uid_foreign)
WHERE s.tablenames = "tt_content"
AND s.deleted = 0
AND c.deleted = 0
GROUP BY uid_foreign, uid_local
@joekolade
joekolade / sticky.js
Created April 8, 2023 14:11
[Sticky element JS]
var sticky = function(elementSelector, heightSelector){
var h = document.querySelector(elementSelector);
var stuck = false;
var stickPoint = getDistance(heightSelector);
function getDistance(heightSelector) {
var topDist = h.offsetTop || document.querySelector(heightSelector).offsetHeight;
return topDist;
}
@joekolade
joekolade / cleanup_typo3.sh
Created March 14, 2023 14:52
[TYPO3 lowlevel cleanup] #refactor
###php_cli### ./typo3/cli_dispatch.phpsh lowlevel_refindex -e
###php_cli### ./typo3/cli_dispatch.phpsh lowlevel_cleaner orphan_records -r ###--dryrun|--AUTOFIX###
###php_cli### ./typo3/cli_dispatch.phpsh lowlevel_cleaner versions -r ###--dryrun|--AUTOFIX###
# Run multiple times
###php_cli### ./typo3/cli_dispatch.phpsh lowlevel_cleaner tx_templavoila_unusedce -r ###--dryrun|--AUTOFIX###
###php_cli### ./typo3/cli_dispatch.phpsh lowlevel_cleaner double_files -r ###--dryrun|--AUTOFIX###
###php_cli### ./typo3/cli_dispatch.phpsh lowlevel_cleaner deleted -r ###--dryrun|--AUTOFIX###
@joekolade
joekolade / upgrade.sh
Created March 14, 2023 14:50
[Mac upgrade software]
# Mac Software Pflege
# update components
upgrade_oh_my_zsh
brew update
composer selfupdate
brew upgrade node
npm install -g npm
nvm install node —latest-npm
nvm install 10 —latest-npm
@joekolade
joekolade / user.typoscript
Created March 14, 2023 14:49
[User TS] Basic user ts #refactor
# Pagetree http://wiki.typo3.org/Pagetree
options.pageTree.backgroundColor.1 = rgba(0, 0, 0, 0.1)
#options.pageTree.showPathAboveMounts = 1
options.pageTree.showPageIdWithTitle = 0
options.pageTree.showDomainNameWithTitle = 1
options.pageTree.showNavTitle = 1
#options.pageTree.hideFilter = 1
#options.contextMenu.table.pages.disableItems = info,history,mountAsTreeroot,expandBranch,collapseBranch
# cache control
@joekolade
joekolade / curl.php
Created March 14, 2023 14:48
[curl call] PHP curl call
/**
* Basic Curl-Call
* @see http://codular.com/curl-with-php
*/
$url = '###URL###';
$token = '122321231';
// Get cURL resource
$curl = curl_init();
@joekolade
joekolade / select.scss
Created March 14, 2023 14:48
[Selectbox CSS]
// @see https://www.macrone.de/das-html-select-element-pure-css-styling/
$base-padding: 8px;
select {
-moz-appearance: none;
-webkit-appearance: none;
appearance: none;
&::-ms-expand {