Alternative to keyword substitution in git, using org-mode

| categories: orgmode, max, git, linux | View Comments

Linus Torvalds thinks that cvs-style keyword substitution (like having the string \(Log\) substituted by actual cvs logs in text file) is idiotic. He's got some points, like avoiding mess in binary files. I think that seeing a log in my org-files is not that bad, and it gives me a notion of the gradual advances that were made. I found the following lines to be non-intrusive enough to make them an almost keyword-substitution-substitution.

# git logging 
#+BEGIN_SRC sh :exports results :results raw drawer
git log | sed -e "s/^/# /g"
\#+END_SRC

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

Backups on OS X

| categories: mac, linux | View Comments

Back to backing up (no pun intended), OS X uses a launchd system rather than "cron.daily". If you are like me, you probably don't want to know why and you don't care. You just want a cron.daily approach, and a way to know whether it worked or not.

So put your bash script from here somewhere on your system, and put the following script in your ~/Library/LaunchAgents/ , with a name like me.bckup.daily.plist (though the name should not matter, or so they tell) :

 1: <?xml version="1.0" encoding="UTF-8"?>
 2: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/
 3: DTDs/PropertyList-1.0.dtd">
 4: <plist version="1.0">
 5: <dict>
 6: <key>Label</key>
 7: <string>me.bckup.daily</string>
 8: <key>LowPriorityIO</key>
 9: <true/>
10: <key>Nice</key>
11: <integer>12</integer>
12: <key>Program</key>
13: <string>/path/to/your/script/bckup_to_hd</string>
14: <key>StartCalendarInterval</key>
15: <dict>
16: <key>Hour</key>
17: <integer>16</integer>
18: <key>Minute</key>
19: <integer>49</integer>
20: </dict>
21: <key>StandardErrorPath</key>
22: <string>/path/to/log_err_file.txt</string>
23: <key>StandardOutPath</key>
24: <string>/path/to/log_out_file.txt</string>
25: </dict>
26: </plist>

with the obvious ammendments of the exact time you want it to be launched every day, and your exact absolute paths.

To begin its action for the first time, either logout and login or :

1: launchctl load me.bckup.daily.plist

If something went wrong, you could use launchctl unload instead of load , get things straight and load again.

Now, how do you know if something went wrong ?

first, you have your log files /path/to/log_*_file.txt . Second, you could search for clues in /private/var/log/system.log in the time you designated.

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

Backups

| categories: mac, linux | View Comments

Backuping should be - routine,automatic, and simple. I'm using the following:

1: rsync --force --ignore-errors --delete \
2:  --exclude /path/to/*excluded_files* \
3:  --backup-dir=`date +%Y-%m` -avb /home/yourname/ \
4:  /path/to/your/BCK/hd

Each month you get a new directory YYYYmm (year+month) on your backup hard drive, for files that have been changed/deleted during this month. You should probably delete it after a few months, but sometimes you will want to recover some data which was mistakenly deleted. Otherwise, all other files (which weren't deleted or modified) are just duplicated to the backup hd.

If you are using linux, you should probably put this script in your /etc/cron.daily/ directory. And give it the correct permissions.

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

Screen - unique logs for each run

| categories: workflow, linux | View Comments

Screen is a little wrap around linux shell that enables detaching and logging out while the session you created is still running. It could be used for lots of different purposes, and running an intensive computation on a remote computer is an obvious example.

You would normally do :

1: screen -md -L -S session_name your_program

-md = detach immediately after running, and return to the current terminal session -L = create a log file -S = create meaningful name for your session

To check the stat of your sessions you will use:

1: screen -ls

To have different log files with unique names for different sessions, you need to create a ~/.screenrc file, with the following single line

logfile screenlog-%Y%m%d-%c:%s

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments

linux copy to clipboard

| categories: alias, workflow, osx, linux | View Comments

Is it true that you have to give names to things to really appreciate and understand them? It's really one of these questions that are just too gross for answering a straight yes or no.

When you think of this question, math comes to mind. I have little doubt that you must internalize dozens of definitions and the relations between them before you master differential geometry, or group theory. But do you need language to understand subtraction? The answer is - NO . Babies do it intuitively. So there is some border beyond which things become too abstract, and we've got to give them names. But isn't my answer a tautology? Isn't "abstract" just the name of this phenomena of having to name something in order to understand it? Sure enough, if we were not so used to giving names to everything, we would have found lots of things "abstract". Helen Keller writes :

"my teacher placed my hand under the spout. As the cool stream gushed over one hand she spelled into the other the word water, first slowly, then rapidly. I stood still, my whole attention fixed upon the motions of her fingers. Suddenly I felt a misty consciousness as of something forgotten - a thrill of returning thought; and somehow the mystery of language was revealed to me. I knew then that "w-a-t-e-r" meant the wonderful cool something that was flowing over my hand"

Most of us don't think of the notion of water as abstract, but it's just a matter of experience.

SO… It didn't occur to me that I need to copy linux outputs to the clipboard, until I found out about xclip (keep your comments about the long intro to yourself, by the way…). Now that I know about it, I also care about cases where I want the trailing '\n', and cases where I don't.

Here are my aliases for linux:

1: alias xc='xclip -selection clipboard'
2: alias xcn='perl -ne "chomp();print" |xclip -selection clipboard'

And here they are for mac osx :

1: alias xc="pbcopy"
2: alias xcn="tr -d '\n' | pbcopy"

The two approaches for removing the newlines work equivalently on both systems.

Copyright (C) 2015 by Avi Gozolchiani. See the License for information about copying.

org-mode source

Read and Post Comments