Summary

I wanted to demo some of the code gen commands using the cli interface with org-babel.

Demos

1
penf -u pf-python-how-to "split a string"
s = "hello world"
print s.split()
# ['hello', 'world']
1
pena -u code-question bash "save an array into a variable"
declare -a arr=([1]=1 [2]=2 [3]=3 [4]=4)
declare -a arr=(1 2 3 4 5)
declare -a array=(a b c d e f g)
save_array=(${!array[@]}
a=(1 2 3 4 5);
b=$a;
c=${b#*#};
# add the array to the end of somefile
arr=($(uname -r -m))
echo "$arr" > /home/user/benchmarks/benchmark
# extract it
cat /home/user/benchmarks/benchmark | grep -Po '
1
pena generate-vim-command "increment numbers on selected lines"
:%s/^\d+/\1+/g
:%s/\d\+/\1+/g
:%s/\d/\1+/g
:%s/\d\+/\=line(".")+1/g
:%s/^\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s\d\+\s
1
pena bash-one-liner-generator-from-natural-language "add a daily cron job to sync home directory to google cloud"
crontab -e
2 0 * * * rsync -ahz --delete -e "ssh -i ~/.ssh/google_compute_engine"
$HOME/ gs://my-bucket/
</nowiki>
# Find all files in current directory that
crontab -e
0 */12 * * * rsync -a --delete ~/ /cloud/
crontab -l | { cat; echo "@daily google-drive sync ~/ s3://mybucket"; }
# delete a file and receive output by email
$ echo "foo" > /root/backup.txt && mail -s "Backup" backup@example
crontab -e
# */5 * * * * rclone sync /home/ <yourusername> @drive.google.com: /home/ <yourusername> --quiet
$ crontab -eย 
# at 23:50 (11:50pm)
crontab -e
$ * * * * * rsync -a ~ / /backup/backup.tar.gz
$ * * * * * rsync -a ~ / /backup/home.tar.gz
$ crontab -l
$ cr
1
pena bash-one-liner-generator-on-os-from-natural-language "arch linux" "delete all packages"
pacman -Rns
pacman -Qq | awk '{print "pacman -Rs " $1 }' | sh
pacman -Qq | pacman -Ql | xargs sudo pacman -Rns
pacman -Q
# Delete all files
pacman -Qq | pacman -Rs
pacman -Qqen *

TODO parameterize the mode-sensitive prompts for the CLI

1
pena -u code-generator-from-description quicksort