Skip to content

Instantly share code, notes, and snippets.

View CDRO's full-sized avatar
😀

Tizian Schmidlin CDRO

😀
View GitHub Profile
@CDRO
CDRO / 0_reuse_code.js
Created January 22, 2014 13:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
/**
* Usage:
* php ./calculate_set_error_reporting.php *somecode*
*/
if($_SERVER['argc'] > 1) {
$errorCode = intval($_SERVER['argv'][1]);
} else {
<?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
*

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
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>');
@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
// ... tx_news class
class PseudoNewsController extends NewsBaseController {
/**
*
*/
public function listAction(Demand $demand /* ... */) {
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
@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 = "
@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__';