Skip to content

Instantly share code, notes, and snippets.

View markuszeller's full-sized avatar
🍪
Eating Cookies

Markus Zeller markuszeller

🍪
Eating Cookies
View GitHub Profile
@markuszeller
markuszeller / xdebug.sh
Created November 6, 2023 18:31 — forked from carstenwindler/xdebug.sh
Bash script to quickly enable / disable xdebug in a PHP docker container
#!/usr/bin/env bash
# see https://carstenwindler.de/php/enable-xdebug-on-demand-in-your-local-docker-environment/
if [ "$#" -ne 1 ]; then
SCRIPT_PATH=`basename "$0"`
echo "Usage: $SCRIPT_PATH enable|disable"
exit 1;
fi
# Expects service to be called app in docker-compose.yml
  1. save agnoster-light.zsh-theme to ~/.oh-my-zsh/themes/.
  2. edit ZSH_THEME in ~/.zshrc to agnoster-light
  3. change the color theme of terminal to solarized-light
  4. open a new terminal
@markuszeller
markuszeller / bash-tricks.md
Last active April 11, 2023 12:31
Bash tricks

60 Seconds backwards timer with counter

i=60;while [ $((i--)) -gt 0 ]; do printf "\r%02d" $i;sleep 1;done;echo

300 Seconds countdown with spinner

i=300;while [ $((i--)) -gt 0 ]; do for s in / - \\ \|; do printf "\r%03d %s" $i $s;sleep .25;done;done;echo

Import .env file into current shell

@markuszeller
markuszeller / vpn.md
Last active January 1, 2021 10:09 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@markuszeller
markuszeller / totp.php
Last active October 1, 2022 18:34
Timed one time password
<?php
$digits = 6;
$interval = 30;
$secret = 'secret_key';
$prevTotp = '';
for ($i = 0; $i < $interval * 4; $i++) {
$time = time();
$counter = (string) floor($time / $interval);
$hmac = hash_hmac('sha1', $counter, $secret);
@markuszeller
markuszeller / base64url.php
Last active October 21, 2020 16:37
Base64URL Support for PHP used for creating JWT (JavaWebToken)
<?php
$header = '{"alg":"HS256","typ":"JWT"}';
$payload = '{"sub":"1234567890","name":"John Doe","role":"user"}';
$encodedHeader = base64url_encode($header);
$encodedPayload = base64url_encode($payload);
$signature = hash_hmac('sha256', "{$encodedHeader}.{$encodedPayload}", 'secret', true);
$signedSignature = base64url_encode($signature);
$jwt = join('.', [$encodedHeader, $encodedPayload, $signedSignature]);
@markuszeller
markuszeller / 50_lines.pde
Created April 27, 2020 12:35 — forked from u-ndefine/50_lines.pde
Sketch of my generative art, "50 Lines"
float decel(float x) { // as an easing function
return 1-(x-1)*(x-1);
}
void setup() {
background(255);
size(750,750,P2D);
PImage img = loadImage("image.png");
strokeWeight(2);
noFill();
@markuszeller
markuszeller / print_r_reverse.php
Created March 18, 2020 11:13 — forked from simivar/print_r_reverse.php
PHP function to reverse print_r function
<?php
/**
* Matt: core
* Trixor: object handling
* lech: Windows suppport
* simivar: null support
*
* @see http://php.net/manual/en/function.print-r.php
**/
function print_r_reverse($input) {
@markuszeller
markuszeller / phpstorm-favourite-plugins.md
Last active June 14, 2021 07:39
Favourite PHP Storm plugins

PHP Storm / Jetbrains IDE recommended plugins

.env files support
.ignore
ANSI Highlighter
Atom Material Icons
BinEd - Binary/Hexadecimal Editor
CMD Support
CodeGlance
CSV Plugin

@markuszeller
markuszeller / Search my gists.md
Created March 9, 2020 11:41 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html