Skip to content

Instantly share code, notes, and snippets.

View KawaiDesu's full-sized avatar
🤔

Oleg Vasilev KawaiDesu

🤔
  • QuadCode
View GitHub Profile
@KawaiDesu
KawaiDesu / script.go
Created November 9, 2017 08:50
Valid shebang for go source files to run them as executable files (scripts)
///usr/bin/env go run "$0" "$@"; exit "$?"
package main
func main(){
println("hello")
}
@KawaiDesu
KawaiDesu / valid_ip.sh
Last active November 2, 2017 07:40
Checks if the input is looks like an IP address
#!/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"
}