Skip to content

Instantly share code, notes, and snippets.

View SVilgelm's full-sized avatar
💻
diving into the Rust && C#

Sergey Vilgelm SVilgelm

💻
diving into the Rust && C#
View GitHub Profile
@SVilgelm
SVilgelm / examples.md
Last active July 22, 2019 13:16
Shell sanitizing, quoting parameters
  • Old code
    exec_cmd('ping {ip}'.format(ip=ip))
    Rewritten code
    exec_cmd(format_cmd('ping {ip}', ip=ip))
    Examples
    format_cmd('ping {ip}', ip="$(rm -rf /)")
    $ ping '$(rm -rf /)'
    ping: cannot resolve $(rm -rf /): Unknown host 
@pteich
pteich / main.go
Last active May 30, 2024 02:57
Example for using go's sync.errgroup together with signal detection signal.NotifyContext to stop all running goroutines
package main
import (
"context"
"errors"
"fmt"
"os/signal"
"syscall"
"time"