Skip to content

Instantly share code, notes, and snippets.

@wrothe
Last active July 16, 2021 01:14
Show Gist options
  • Save wrothe/ea01ddb2bf91f78ed5d0a644fab6f9c5 to your computer and use it in GitHub Desktop.
Save wrothe/ea01ddb2bf91f78ed5d0a644fab6f9c5 to your computer and use it in GitHub Desktop.
# stupid xonsh tricks
# These aren't current, 0.8.X maybe?
# https://xon.sh
from datetime import datetime
cp test @(test + datetime.now().strftime("%Y%m%d"))
# space with mtime
cp 'Dropbox (Sparkred)/serverlist' @('Dropbox (Sparkred)/serverlist' + date.fromtimestamp(os.stat('Dropbox (Sparkred)/serverlist')[8]).strftime('%F'))
# use python re
for i in `epcc_cloud_.*`:
echo @(i)
for i in range(11,17):
![ping -c1 @('rhw-prd-dal-app-' + str(i) + '-p')]
for i in '''46.51.145.201
34.254.148.133'''.splitlines():
print(i)
for i in ![host -t ns easydns.com | cut '-d ' -f4]:
print(i)
# stat
import os, sys
os.stat('path/file')
os.stat_result(st_mode=33188, st_ino=13337148, st_dev=16777220, st_nlink=1, st_uid=501, st_gid=20, st_size=308335, st_atime=1547435351, st_mtime=1546978494, st_ctime=1546978494)
# st_mtime is 8th element
os.stat('path/file')[8]
1546978494
# xontrib pipeliner; pip install xontrib-pipeliner
grep -v '^#' /etc/passwd | head -3 | pl "line.split(':')[6]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment