Posts Tagged ‘commandline’
Here’s one way. There’s a C program to adjust the screen’s brightness written by Nicholas Riley, also available from this blog post by Matt (Danger) West. Get it. The rest is obvious. For instance, here’s a Python script, which should have probably been written in Perl:
import os, re, time s = os.popen('./brightness -l').read() ob = re.findall('brightness (\d.\d+)', s) w = 0.2 for i in range(10): os.system('./brightness 0'); time.sleep(w) os.system('./brightness 1'); time.sleep(w) if(i==4): os.system("say beep") os.system('./brightness ' + ob)
Tune parameters to avoid epileptic seizures.
Something is wrong with the network in my dorm; DHCP negotiation sometimes fails (or takes a long time). So the usual thing to do is to turn Airport off and on, and hope it works this time.
To do this from the commandline, here’s a simple trick I found:
Go to System Preferences → Network, then in Location choose a New Location and create one called “Airport-Off” (or anything you like). In the Show menu choose Network Port Configurations and turn off Airport.
After this, you can do scselect Airport-Off to turn it off, and scselect 0 (for Automatic — or choose whatever other location you want) to turn it on.
Edit [2011-10-03]: You can also do this:
sudo networksetup -setairportpower "Airport" off sudo networksetup -setairportpower "Airport" on
As Gmail has IMAP access, it is fairly trivial to get it working with mutt. First, if you’re on Ubuntu/Debian, run
sudo apt-get install openssl mutt to get mutt if you don’t already have it. Then, just put the following lines into your ~/.muttrc:
set imap_user = "email@example.com" set imap_pass = "password" set smtp_url = "smtp://firstname.lastname@example.org:587/" set smtp_pass = "password" set from = "email@example.com" set realname = "Your Real Name" set folder = "imaps://imap.gmail.com:993" set spoolfile = "+INBOX" set postponed="+[Gmail]/Drafts" set header_cache=~/.mutt/cache/headers set message_cachedir=~/.mutt/cache/bodies set certificate_file=~/.mutt/certificates set move = no
Make sure your ~/.muttrc isn’t world-readable; it contains your password. (Alternatively, you can leave them out and mutt will prompt you for the password each time.) Also, if you copy-paste from the above, make sure that you have only “normal” quotes, not “smart quotes” which WordPress might have inserted here into this post.
[Other things I have:
set sort = 'threads' set sort_aux = 'last-date-received' set imap_check_subscribed ignore "Authentication-Results:" ignore "DomainKey-Signature:" ignore "DKIM-Signature:" hdr_order Date From To Cc
I did not include above to justify the “minimal” :)]
Things work perfectly as you would expect them.
One thing to note is that the full headers will still contain the hostname of the computer you send messages from. I have not figured a way of hiding this, and perhaps it shouldn’t be possible.
If for some reason you want to use POP, read on. And tell me why you would want to use POP. The rest of the post is an old version, which i had written before Gmail supported IMAP.
There is a guide here, which is the first Google result on searching for the keywords Gmail, mutt and Ubuntu in any order, but I would advise against it: it does too much unnecessary stuff using too many unnecessary programs (okay if you don’t care)
, and involves putting your username and password in a world-readable file (not okay).
There is a guide here, but that site seems down, and so I guess it’s likely to be down again (a DynDNS domain; could be someone’s house), so putting a (fuller) guide here:
sudo apt-get install openssl mutt
Next, in /etc/ssmtp/ssmtp.conf, put
Everything else seems to be optional.
Next, create a shell script with the contents
and put it somewhere in your path (~/bin/gmailout, say) and make it executable (chmod u+x ~/bin/gmailout, I mean) and make sure only you can read it! (chmod og-r ~/bin/gmailout).
/usr/sbin/ssmtp -au "gmail-address" -ap "password" $@
Now in ~/.muttrc, put
unset pop_delete #Just makes mutt not ask, GMail uses config option
set write_bcc=no #Important; sSMTP makes bcc non-blind otherwise
and you’re set (remember to make this world-unreadable too: chmod og-rw ~/.muttrc)
You can start mutt, and hit “G” (uppercase G) whenever you want to fetch mail. Can also put exec fetch-mail in ~/.muttrc to have it happen whenever you start mutt, but I find that irritating.
Problems with POP: Not that everything is perfect. I can’t have other mail-transport-agents like sendmail or postfix installed alongside ssmtp. I can’t figure out how to get my crontab reports sent to root, but they do go into ~/dead.letter :D
Also, with mutt I had the habit of adding a my_hdr bcc: my-email-address so that the mail I send is threaded along with the mail I receive (yaay, like Gmail), but somehow there seems to be simply no way of getting Gmail to give me, through POP, those messages I send using an external client. It’s a quirk [bug!] in the way Gmail implements POP. This I’ve fixed by setting mutt’s fcc to /var/mail/my-username, my mail folder. (Of course, if I were in the habit of moving mail to my mbox, I could fcc to mbox too.)
Apart from that, it works fine!
All things considered (after trawling through more than a dozen pages of Google results, that is), I’ve arrived at the conclusion that the best way [as of 2006-10-11] to work on LaTeX documents collaboratively is to use a CVS or Subversion repository, and let everyone commit changes to it.
There seems to be a MediaWiki plugin for collaborative LaTeX, but it needs some attention to security issues…
There’s a very short CVS tutorial here.
Update[2007-11-25]: For some reason, the PracTeX journal had three articles about LaTeX+Subversion in 2007-08: LaTeX Document Management with Subversion, Version Control of LaTeX Documents with svn-multi, and Subversion and TextMate: Making collaboration easier for LaTeX users. It’s a good idea to pick the simplest solution that works for you. I haven’t read those articles, but we did use LaTeX in a (somewhat) collaborative way (we weren’t sharing the work much, so it’s not clear the others saw any good in it) for two of our courses, here and here. The websvn interface is a bit crufty; we were using the commandline interface.
The work cycle was as below: (in case you’ve never used version control and don’t know what it is, this will show you that it’s simple after all!)
[Don’t use these URLs; they won’t work for you, of course.]
How to use the algcomp-notes subversion repository. ==Initial setup (only once)== svn checkout http://svn.cmi.ac.in/algcomp-notes/ working-dir ==Work cycle (each time)== svn update # to get the latest version from the repository Now work with your files as you usually would. After you're done, do: svn diff #optional: to see what you have changed svn commit -m "some message, for the history" Extra files you create in the directory are ignored. To add a new file, use: svn add [filename]
That’s all there is to it (apart from setting up — or getting someone to set up — the repository and access to it in the first place. Ask your sysadmin :-)
Update[2008-02-05]: Gobby is a collaborative text editor, and can be used with LaTeX, as this screenshot shows. Someone even wants to use Darcs’s Theory of Patches, and give it proper Undo etc… and at that point we are back to the version control solution, but with a good version-control system and a simple GUI for doing things.
Update[2008-03-25]: Here is a post by an actual mathematician using version control.
I do think it would be a great idea for someone to provide a version-control service for collaborative LaTeX documents over the internet. They could go further and make it easy to edit LaTeX in a browser, and we would have something along the lines of Google Docs.
Update [2009-10-03]: Some other things worth a mention: online LaTeX editors like MonkeyTex (but no one really likes editing in anything other than their familiar environment), a page at Wikibooks based on one of the PracTeX articles mentioned above, and, coming Real Soon Now, support for LaTeX in Google Wave.(link.)
Update [2010-05-11]: Some more things to mention: ScribTeX (see comments below), and LaTeX-lab, a plugin for Google Docs.
Update [2010-06-23]: Also see this Mathoverflow thread called Tools for Collaborative Paper Writing.
To set up an ssh-key usually, type
ssh-keygen -t rsa, hit [Enter] a few times, type
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys, and add entries from other places where you might have created a key, to the same authorized_keys.
To set it up so you can log in as another user (called, say, user2)
ssh-keygen -t rsa
Enter a different file to save (id_for_user2, say), and blank passphrase.
Now add the contents of the file id_for_user2.pub to user2‘s ~/.ssh/authorized_keys file.
Oh, and when you want to login as that user, you will have to specify that you want to use that file, like
ssh -i ~/.ssh/id_for_user2 user2@hostname. For long commands like this, it’s best to make an alias (put alias sshasuser2='ssh -i ~/.ssh/id_for_user2 user2@localhost' in your ~/.bashrc if all you want is a password-less replacement for su - user2). You can also give the id_for_user2 file to others, and they can also login as user2 without a password simply by typing the command above.
Got it from this linux.debian.user newsgroup post.