This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) { | |
// path/to/whatever does not exist | |
} | |
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) { | |
// path/to/whatever exists | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_local_timezone_str | |
# Yes, this is actually a shell script… | |
olsontz = `if [ -f /etc/timezone ]; then | |
cat /etc/timezone | |
elif [ -h /etc/localtime ]; then | |
readlink /etc/localtime | sed "s/\\/usr\\/share\\/zoneinfo\\///" | |
else | |
checksum=\`md5sum /etc/localtime | cut -d' ' -f1\` | |
find /usr/share/zoneinfo/ -type f -exec md5sum {} \\; | grep "^$checksum" | sed "s/.*\\/usr\\/share\\/zoneinfo\\///" | head -n 1 | |
fi`.chomp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/ajstarks/svgo" | |
"os" | |
) | |
var canvas = svg.New(os.Stdout) | |
// sparkline defines the components of the sparkline: |