Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Tizian Schmidlin CDRO

Block or report user

Report or block CDRO

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@CDRO
CDRO / download.phpt
Created Oct 4, 2018
A safe single download for files in PHP
View download.phpt
<?php
if(file_exists(__FILE__ . '.downloaded')) {
header('Location:/');
die;
}
touch(__FILE__ . '.downloaded');
$file = '__REPLACE_ME_FILE_PATH__';
@CDRO
CDRO / Networking Scripts
Created Jul 31, 2018
This is a collection of handy networking on-liners
View Networking Scripts
# Find all registered machines in your network
for i in $(seq 1 254); nslookup 192.168.23.$i | grep "name = "
View Dockerfile
FROM alpine
RUN touch ~/.profile
RUN apk add --no-cache curl bash nodejs
RUN curl -o- -L https://yarnpkg.com/install.sh | bash
RUN echo $HOME
ENV PATH="root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:${PATH}"
RUN echo $PATH
RUN yarn -v
View PseudoNewsController.php
<?php
// ... tx_news class
class PseudoNewsController extends NewsBaseController {
/**
*
*/
public function listAction(Demand $demand /* ... */) {
@CDRO
CDRO / check_valid_images.php
Created Feb 21, 2018
TYPO3 check if fe_users have valid images
View check_valid_images.php
<?php
/**
* Either execute the script on the shell or directly in the browser.
* Place the script in the webroot and call it.
*/
if(php_sapi_name() !== 'cli') {
echo '<pre>';
}
echo 'Connecting', PHP_EOL;
$m = new mysqli('localhost', 'name', '***', 'db');
View sorting-examples.php
<?php
// fill array
$objects = [];
for($i = 0; $i < 100; ++$i) {
$o = new stdClass;
$o->val = $i * mt_rand() * 1000;
$objects[] = $o;
}
View Proper die message.php
<?php
die('<iframe width="560" height="315" src="https://www.youtube.com/embed/Xw-m4jEY-Ns?rel=0&amp;controls=0&amp;autoplay=1&amp;start=69" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>');
View Regulary check state of folder.md

This is an easy script that lets you countdown after having checked the size of a folder.

I used this to monitor the state of a file transfer with lots of small file and no proper progress bar.

Credit for the counter go to dsmsk80(https://serverfault.com/questions/532559/bash-script-count-down-5-minutes-display-on-single-line#answer-532564)

Inline version (replace interval)

interval=30; while true; do clear; echo du -hs `pwd`/\*; du -hs * ;  secs=$interval; while [ $secs -gt 0 ]; do echo -ne "Refresh in $secs seconds\033[0K\r"; sleep 1; : $((secs--)); done; done
View ReplaceOldClassNames.php
<?php
/***************************************************************
* Copyright notice
*
* (c) 2016 Nils Blattner <nb@cabag.ch>, cab services ag
* (c) 2017 Tizian Schmidlin <st@cabag.ch> cab services ag
*
* All rights reserved
*
View calculate_set_error_reporting.php
<?php
/**
* Usage:
* php ./calculate_set_error_reporting.php *somecode*
*/
if($_SERVER['argc'] > 1) {
$errorCode = intval($_SERVER['argv'][1]);
} else {
You can’t perform that action at this time.