Skip to content

Instantly share code, notes, and snippets.

View janstieler's full-sized avatar

Jan janstieler

View GitHub Profile
@janstieler
janstieler / rename.php
Created February 23, 2021 23:13
PHP Rename Files in Folder
<?php
$dir = 'images/';
$files = scandir($dir);
foreach($files as $i => $name) {
if($i > 2){
$filename = $name;
$newname = $i-2 . '_' . $filename;
if ($newname != $filename) {
rename($dir.$filename, $dir.$newname);
@janstieler
janstieler / compressfiles.func.php
Last active July 31, 2020 03:31
PHP function for compress .css or .js files with a timestamp.
<?php
function compressFiles(array $files){
$debug = false;
$buffer = '';
$firstFile = $files[0];
if($debug === true){
switch(pathinfo($firstFile)['extension']){
case 'css':
foreach ($files as $file) {
@janstieler
janstieler / scarppy_img.py
Created September 7, 2019 19:30
python scrappy file for crawl a website for imgs with alt-tag.
import scrapy
class MySpider(CrawlSpider):
name = 'imageaggr'
start_urls = ['https://www.datagon.de']
rules = (
# Extract links matching 'category.php' (but not matching 'subsection.php')
# and follow links from them (since no callback means follow=True by default).
@janstieler
janstieler / add.php
Last active November 2, 2018 17:37
Remove Templates from Module adding form
site/plugins/sortable/sortable/actions/add/forms/add.php
foreach($page->blueprint()->pages()->template()->filterBy('name', '*=', $field->prefix()) as $template) {
$options[$template->name()] = $template->title();
}
@janstieler
janstieler / new_gist_file.js
Created August 24, 2017 15:26
List of countries for Select2 (https://select2.github.io/) where the id is identically to the text.
[
{ id: 'Afghanistan', text: 'Afghanistan'},
{ id: 'Aland Islands', text: 'Aland Islands'},
{ id: 'Albania', text: 'Albania'},
{ id: 'Algeria', text: 'Algeria'},
{ id: 'American Samoa', text: 'American Samoa'},
{ id: 'Andorra', text: 'Andorra'},
{ id: 'Angola', text: 'Angola'},
{ id: 'Anguilla', text: 'Anguilla'},
{ id: 'Antarctica', text: 'Antarctica'},
@janstieler
janstieler / script.js
Created July 4, 2017 23:30
Feuerwehr JS Script
function stuffForResizeAndReady(){
var doc = jQuery(document),
windowWidth = jQuery(window).innerWidth(),
windowHeight = jQuery(window).innerHeight(),
container = jQuery('body > .container'),
containerWidth = container.width(),
containerPadding = (container.outerWidth() - containerWidth) / 2,
menu = jQuery('#hauptmenue_e1'),
menuPosition = menu.offset(),
kopfteilOben = jQuery('#kopfteil_oben'),
{
"metadata": {
"name": "Sevendays Icons",
"lastOpened": 1418773394855,
"created": 1497381487453
},
"iconSets": [
{
"selection": [
{
@janstieler
janstieler / header.php
Last active May 30, 2017 14:37
Kirby Header
<!DOCTYPE html>
<!-- Die Ausrichtung der Sprache der Webseite, hier: Deutsch -->
<html class="no-js" lang="<?php echo $site->languages()->code() ?>">
<head>
<!-- Zeichencodierung, damit Umlaute und ähnliches korrekt dargestellt werden -->
<meta charset="utf-8">
<!-- Verwende die neueste, beim Benutzer, verfügbare InternetExplorer Version -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Löse die URLs von externen Quellen vor dem Laden der Datei auf – sollte dann etwas schneller laden. Beispielhaft: -->
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
<?php
defined('JPATH_BASE') or die;
// Import the Profile Picture library
jimport('profilepicture.profilepicture');
// Get the current user object
$user = JFactory::getUser();
// Instantiate the ProfilePicture class with User ID
<form class="contactform" action="" method="post" accept-charset="UTF-8" role="form">
<?php if($contactalert): ?>
<div class="alert" role="alert">
<h4 class="pull-left"><?php echo l::get('alert')?></h4>
<button type="button" class="unloadalert btn btn-default-white pull-right" aria-label="Close"><i class="icon-cross" aria-hidden="true"></i></button>
<ul style="clear: both">
<?php foreach($contactalert as $contactmessage): ?>
<li><?php echo html($contactmessage) ?></li>
<?php endforeach ?>
</ul>