Skip to content

Instantly share code, notes, and snippets.

View joekolade's full-sized avatar

Joe Kolade joekolade

View GitHub Profile
@joekolade
joekolade / snippet.php
Last active March 3, 2023 11:08
[Debug per IP] PHP Debug information based on request IP #typo3
if($_SERVER['REMOTE_ADDR'] == '37.209.17.41'){
var_dump($var);
exit;
}
@joekolade
joekolade / debounce.js
Created March 3, 2023 11:21
[JS Debounce] Simple debouncer function
/*
@param : fn => the function to convert
@param : time => the time delay for debounce
*/
function debounce(fn, delay) {
let timer = null
return (...args) => {
if (timer) clearTimeout(timer)
timer = setTimeout(() => fn(...args), delay)
@joekolade
joekolade / crawl-site.py
Last active March 3, 2023 15:24
[scrapy site crawler] crawls a whole site
# run with
# `scrapy runspider crawl-site.py`
import scrapy
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
class MySpider(CrawlSpider):
name = 'domain.com'
allowed_domains = ['domain.com']
@joekolade
joekolade / commands.sh
Last active March 4, 2023 21:28
[tar] Tar commands for everyday use
# Create tar.gz archive
tar -czvf archive.tar.gz what_to_pack
# Extract zipper archive
tar xzf archive.tar.gz
@joekolade
joekolade / .editorconfig
Created March 10, 2023 11:23
[.editorconfig]
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]a
# change these settings to your own preference
@joekolade
joekolade / 404.html
Created March 10, 2023 11:24
[404 Dummy] formale dummyseite
<p>Die angeforderte Seite konnte vom Webserver nicht gefunden werden, daher lieferte dieser den Fehler 404 zurück.</p>
<p>404-Fehler können auftreten, wenn…</p>
<div>…Sie als Besucher einen fehlerhaften Link eintippen,
<br />…eine Suchmaschine auf eine veraltete Webseite verlinkt,
<br />…die Webseite verzogen oder gelöscht wurde.</div>
<div>
<p>Besuchen Sie doch unsere Startseite, Sie finden dort bestimmt wonach sie suchten: <a href="/" title="Zur Startseite" rel="nofollow">Startseite von ###WEBSEITENNAME###</a></p>
</div>
@joekolade
joekolade / svgsprite.js
Created March 10, 2023 11:25
[JS load SVG sprite]
// @see https://css-tricks.com/ajaxing-svg-sprite/
var ajax = new XMLHttpRequest();
ajax.open("GET", "svg/sprite.svg", true);
ajax.send();
ajax.onload = function(e) {
var div = document.createElement("div");
div.innerHTML = ajax.responseText;
document.body.insertBefore(div, document.body.childNodes[0]);
}
@joekolade
joekolade / setup.typoscript
Created March 10, 2023 11:26
[Ajax page] Configure an ajax page in typoscipt
ajax_###myextension### = PAGE
ajax_###myextension### {
typeNum = 6661
typeNum = {$plugin.tx_###myextension###.settings.###ajaxpagetype###}
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
additionalHeaders = Content-type: text/plain
@joekolade
joekolade / backup_mysql.sh
Created March 10, 2023 11:28
[Backup mysql via mysqldump]
mysqldump -u ###user### -p###password### ###dbname### > ###dbname###_@date.sql
@joekolade
joekolade / hmenu.typoscript
Created March 14, 2023 14:44
[HMENU] Hmenu in typoscript #refactor
/**
* Menu-Prototype
*/
###menu### = HMENU
###menu### {
# entryLevel = 1
# special = directory
# special.value = ###pid###
1 = TMENU