Skip to content

Instantly share code, notes, and snippets.

View CDRO's full-sized avatar
😀

Tizian Schmidlin CDRO

😀
View GitHub Profile

Keybase proof

I hereby claim:

  • I am CDRO on github.
  • I am tschmidlincab (https://keybase.io/tschmidlincab) on keybase.
  • I have a public key whose fingerprint is 6697 0C1D 2F43 A3EE D4AE 6947 29BE D76B 115A F72F

To claim this, I am signing this object:

@CDRO
CDRO / download.phpt
Created October 4, 2018 11:07
A safe single download for files in PHP
<?php
if(file_exists(__FILE__ . '.downloaded')) {
header('Location:/');
die;
}
touch(__FILE__ . '.downloaded');
$file = '__REPLACE_ME_FILE_PATH__';
@CDRO
CDRO / Networking Scripts
Created July 31, 2018 09:28
This is a collection of handy networking on-liners
# Find all registered machines in your network
for i in $(seq 1 254); nslookup 192.168.23.$i | grep "name = "
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
<?php
// ... tx_news class
class PseudoNewsController extends NewsBaseController {
/**
*
*/
public function listAction(Demand $demand /* ... */) {
@CDRO
CDRO / check_valid_images.php
Created February 21, 2018 12:53
TYPO3 check if fe_users have valid images
<?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');
<?php
// fill array
$objects = [];
for($i = 0; $i < 100; ++$i) {
$o = new stdClass;
$o->val = $i * mt_rand() * 1000;
$objects[] = $o;
}
<?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>');

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
<?php
/***************************************************************
* Copyright notice
*
* (c) 2016 Nils Blattner <[email protected]>, cab services ag
* (c) 2017 Tizian Schmidlin <[email protected]> cab services ag
*
* All rights reserved
*