Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Oleg "Zmey!" Vasiliev KawaiDesu

🤔
  • QuadCode
  • Sankt-Peterburg
View GitHub Profile
@KawaiDesu
KawaiDesu / script.go
Created Nov 9, 2017
Valid shebang for go source files to run them as executable files (scripts)
View script.go
///usr/bin/env go run "$0" "$@"; exit "$?"
package main
func main(){
println("hello")
}
@KawaiDesu
KawaiDesu / valid_ip.sh
Last active Nov 2, 2017
Checks if the input is looks like an IP address
View valid_ip.sh
#!/bin/bash
valid_ip(){ # (ip)
local INVALID=0
grep -Eq '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' <<< "$1" || INVALID=1
for N in $(echo "$1" | tr '.' ' '); do
test "$N" -gt 255 && INVALID=1;
done
return "$INVALID"
}