Posts Tagged ‘compknow’
mplayer: changing speed without changing pitch (avoiding the chipmunk effect)
In mplayer, you can change the playback speed with [ or ], but that probably changes the pitch as well (naturally). Can be amusing the first time, but not after you realise that it is actually possible to do something sophisticated to avoid this. (Wikipedia calls it Audio timescale-pitch modification) Many other media players (including VLC and even Windows Media Player(?)) can do this automatically; here’s how to do it in mplayer.
Short answer:
Start mplayer as mplayer -af scaletempo
That’s it. The catch is that you need to get an mplayer which has the scaletempo filter, and we know how much the mplayer project loves making releases. (It’s not in Ubuntu at the time of writing.)
So, either
Get such an mplayer
e.g the deb from Sourceforge (here),
or
Start mplayer as mplayer -speed 1.5 -af ladspa=tap_pitch:tap_pitch:0:-33:-90:0 foo.avi
Seems even the latter might require installing the ladspa plugins.
For more on all this, see:
- blog comments (with patches) at Pitch-Correct Play Speed with MPlayer
- Change MPlayer Playback Speed
- Mplayer FAQ: “How do i change mplayer speed but keep pitch the same?”
Zsh/Bash startup files loading order (.bashrc, .zshrc etc.)
If you have ever put something in a file like .bashrc and had it not work, or are confused by why there are so many different files — .bashrc, .bash_profile, .bash_login, .profile etc. — and what they do, this is for you.
The issue is that Bash sources from a different file based on what kind of shell it thinks it is in. For an “interactive non-login shell”, it reads .bashrc, but for an “interactive login shell” it reads from the first of .bash_profile, .bash_login and .profile (only). There is no sane reason why this should be so; it’s just historical. Follows in more detail.
For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C, etc. The B1, B2, B3 means it executes only the first of those files found.
+----------------+-----------+-----------+------+ | |Interactive|Interactive|Script| | |login |non-login | | +----------------+-----------+-----------+------+ |/etc/profile | A | | | +----------------+-----------+-----------+------+ |/etc/bash.bashrc| | A | | +----------------+-----------+-----------+------+ |~/.bashrc | | B | | +----------------+-----------+-----------+------+ |~/.bash_profile | B1 | | | +----------------+-----------+-----------+------+ |~/.bash_login | B2 | | | +----------------+-----------+-----------+------+ |~/.profile | B3 | | | +----------------+-----------+-----------+------+ |BASH_ENV | | | A | +----------------+-----------+-----------+------+ | | | | | +----------------+-----------+-----------+------+ | | | | | +----------------+-----------+-----------+------+ |~/.bash_logout | C | | | +----------------+-----------+-----------+------+
In more detail is this excellent flowchart from http://www.solipsys.co.uk/new/BashInitialisationFiles.html :
Typically, most users will encounter a login shell only if either:
* they logged in from a tty, not through a GUI
* they logged in remotely, such as through ssh.
If the shell was started any other way, such as through GNOME’s gnome-terminal or KDE’s konsole, then it is typically not a login shell — the login shell was what started GNOME or KDE behind your back when you logged in; things started anew are not login shells. New terminals or new screen windows you open are not login shells either. (Starting a new window in OS X’s Terminal.app seems to count as a login shell, though.)
So typically (or sooner or later), what you will encounter are non-login shells. So this case is what you should write your config files for. This means Read the rest of this entry »
Commandline MPlayer on OS X
The OS X build of Mplayer (from the official site) does have good old mplayer buried in it; it’s at
"/Applications/MPlayer OSX.app/Contents/Resources/External_Binaries/mplayer_intel.app/Contents/MacOS/mplayer"
It may also be at
/Applications/MPlayer OS X 2.app/Contents/Resources/mplayer.app/Contents/MacOS/mplayer
on other builds.
Found it thanks to this blog.
Also, the OSD (subtitles, fonts) by default doesn’t “just work” on OS X; you have to symlink a ttf file into ~/.mplayer/subfont.ttf
There are some TTF fonts in /Library/Fonts/; you can try locate .ttf
to find more. (Or download, of course.)
Goodbye Adium: Pidgin on Mac OS X… with native GTK!
So you’re on Mac OS X, and want to use Pidgin on it.
First: Why not use Adium? Adium is a Free multi-protocol IM client for Mac OS X that uses libpurple, the IM library that was developed as part of Pidgin. It has several popular features such as message styles, and uses the Cocoa API native to Mac OS X, and all round looks pretty. Being a native Cocoa application, it is more well-integrated with the Mac desktop than a GTK-using application like Pidgin can ever be.
On the other hand, if you, like me, have tried Adium and have reasons for finding it unusable, then it is possible to install Pidgin on OS X too. There are two ways of doing this:
[Edit: Note that this post is from 2007. Probably a lot has changed since then.]
- Install Pidgin to run inside X11. Any default distribution of Pidgin should build fine on this, as long as you have all the dependencies installed. However, using an X11 app on OS X is really like entering another universe entirely… it’s like having two entirely disjoint OSes that just happen to run simultaneously. It is cumbersome, and I would not recommend it unless you are already doing much of your work inside X11 for some reason.
- Install Pidgin to run on the Mac desktop directly (without X11), using native GTK+ for Mac OS X and some minor modifications to Pidgin. This is very simple to do and requires only one step, described below.
Instructions:
Firefox: Subscribing to feeds using Google Reader
If I select a feed URL (or “live bookmark” as Firefox likes to call it), and choose to “subscribe to this feed using: Google”, I am taken to a Google page that always shows two options, “Add to Google homepage” and “Add to Google Reader”. Is there a way of directly going to Google Reader each time?
Yes: Auto add to Google Reader, a Greasemonkey script.
It probably works; but I’m using an alpha release of Firefox 3 (“Gran Paradiso”), and Greasemonkey doesn’t work for me so I can’t be sure.
Using Gmail with mutt, the minimal way (IMAP update)
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 = "username@gmail.com" set imap_pass = "password" set smtp_url = "smtp://username@smtp.gmail.com:587/" set smtp_pass = "password" set from = "username@gmail.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.
The End
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.
Old Stuff
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:
First, run sudo apt-get install openssl mutt
Next, in /etc/ssmtp/ssmtp.conf, put
mailhub=smtp.gmail.com:465
UseTLS=YES
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).
#!/bin/sh
/usr/sbin/ssmtp -au "gmail-address" -ap "password" $@
Now in ~/.muttrc, put
set pop_host="pops://username:password@pop.gmail.com:995"
set pop_last
unset pop_delete #Just makes mutt not ask, GMail uses config option
set sendmail="~/bin/gmailout"
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!
Symbol’s function definition is void: outline-font-lock-level
Using Emacs and todoo-mode (the todoo library / todoo.el).
I got the message
Symbol’s function definition is void: outline-font-lock-level
whenever I tried to insert a new sub-item (using C-c M-i which is bound to todoo-insert-sub-item) in my TODO file. Searching Google gave someone’s old diary, from which (although it’s in Japanese ;-)) I found that it’s related to Debian bug 244681: emacs-goodies-el: todoo.el doesn’t work at XEmacs21. I’m using GNU Emacs 22.0.92.1 and not XEmacs, though.
Update: Before you try the “fixes” below (and in the comment), try just downloading the latest version from Debian. It appears that this got reported as bug 447760, and got fixed.
Anyway, the fix (I haven’t learnt Emacs lisp, so this may be far from the “best” way to do it):
- Open the todoo.el file (M-x find-library RET todoo RET) and find the todoo-insert-sub-item function. (Better, use C-h f todoo-insert-sub-item RET and follow the link.)
- Replace (outline-font-lock-level) with a value, like 3 or something. You might also want to do the same in the other place that (outline-font-lock-level) is used — in the function todoo-indent-line
Another solution, if you don’t want to / can’t edit the file (no permissions, for example), might be to define the function (outline-font-lock-level) — put (defun outline-font-lock-level nil 3) somewhere.
Another solution might be to redefine the function entirely. This requires knowledge that I don’t have, but, for example, making some local transformations, I replaced it with this:
(defun todoo-insert-sub-item () "Insert a new todoo-sub-item." (interactive) (goto-char (- (todoo-item-end) 1)) (insert (concat (make-string todoo-indent-column ? ) todoo-sub-item-marker " \n")) (backward-char))
The space after the ? is important.
Using Emacsclient
Emacsclient, essentially, says “use a running emacs”. With it, you can have only copy of Emacs running, and every time you need to edit something, you can call “emacsclient filename” to use the existing instance of Emacs without having to wait several seconds for a new one to start. To use it, simply put (server-start) in ~/.emacs, or type M-x server-start from within Emacs.
There are two (minor, irritating) problems with it, though:
- When you are done with a file, you have to close it by hitting C-x #. Closing it normally (hitting C-x k, or exiting Emacs) brings up an annoying
Buffer `buffername' still has clients; kill it?
message. The rationale for this is in server.el:
;; Ask before killing a server buffer. ;; It was suggested to release its client instead, ;; but I think that is dangerous--the client would proceed ;; using whatever is on disk in that file. -- rms.
I don’t see what’s dangerous about that, but then again, I’m not RMS! …
One could put something like (global-set-key (kbd "C-x C-k") 'server-edit) to replace C-x # by an easier keystroke, but I found a better solution to be to remove the thing altogether, assuming that you’re going to be careful against whatever it is that is dangerous:(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)
Remember to put this after the (server-start) line in .emacs (If you’re doing M-x server-start manually, you’ll have to call the above remove-hook manually too.) After doing this, you can simply save and close the buffer as usual (or even quit Emacs), and everything will work fine — you won’t get the annoying message any more.
- The second problem is that when you call emacsclient from a shell, although the file gets loaded in Emacs, the Emacs window rarely pops up, at least on GNOME and KDE (and, on hearsay, OS X as well). It was suggested to put (add-hook 'server-switch-hook 'raise-frame) somewhere, but that doesn’t work either. (In KDE, it only flashes the Emacs window in the task bar, but that is better than nothing, as Ctrl-Alt-A is KDE’s shortcut for “Activate window demanding attention”.)
At least it appears that peoplearewere discussing it of late, in a gnu.emacs.help thread “raise frame no go”, and related discussions here, and also a GNOME bug here. These discussions are specific to Metacity (GNOME’s default WM), but it also doesn’t work on KDE and Cygwin.
Oh, and if you’re on OS X, you can turn emacsclient into a .app with Platypus. (Although you probably don’t really need it…)
Update: Emacsclient just got a lot more friendly. You no longer have to go find where the original emacs “server” was started — you can simply start up a new frame for your new buffer, wherever you want (all such Emacs “instances” share the same buffers). This makes the second problem above entirely irrelevant. (It seems to be an Emacs tradition to give up on fixing things that don’t work and implement something better instead :P) Read more about it.
k3b verification “Could not find file”
Enable “Allow lowercase characters in ISO9660 file names”. Reported at https://launchpad.net/distros/ubuntu/+source/k3b/+bug/59089 and http://bugs.kde.org/show_bug.cgi?id=119544
Update: Probably fixed by now.
Other annoying k3b bugs:
- When it ejects and reloads the CD for verification, KDE pops up a “What do you want to do?” thing that comes when CDs are inserted.
- When it ejects and cannot reload the CD (it happens often with old drives) it aborts, instead of asking the user to put the CD in.
Collaborative work with LaTeX
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…
Someone asked around, and put up an extremely useful summary.
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.
MusicIndiaOnline on Linux
I’m on Linux, Ubuntu 6.06 (“Dapper Drake”) to be precise.
If you are having trouble getting Music India Online to work, here are some things you can do:
- After their Trident music player has launched and complained about “Methods missing” (or loads, but clicking on “Play” doesn’t do anything), right-click in the Player’s frame, This Frame → View Frame Source, search for the .smil file (not the blank.smil, the other one). Now you have the URL of the SMIL file, and can open it using, e.g., Real Player’s “Open Location” with that URL. This should always work.
- The above is painful, and Greasemonkey can automate it. Try this script by Supratim (see comments). I haven’t tried this myself.
- It’s possible that all you need to do is install a newer version of Real Player. One of the commenter says that it’s a bug in realplayer 10.0.x, and you can install a Realplayer 10.1.x. You can get one from here. (If you can get it through your distro’s package management system, it would be safer and less messier, of course, but..) Friends have told me that doing this is sufficient to get musicindiaonline working.
- Going further, you can configure Firefox to make it use an external handler (realplayer) for streaming. Set network.protocol-handler.external.rtsp=true and set network.protocol-handler.app.rtsp to your realplayer binary. See the commenter’s page.
For some reason, their “Radio” section (radio.musicindiaonline.com) works perfectly.
Please leave any further suggestions in the comments.
dpkg error: trying to overwrite X, which is also in package Y
For an error like this:
dpkg: error processing /var/cache/apt/archives/AAA (--unpack): trying to overwrite `/usr/lib/BBB', which is also in package CCC dpkg-deb: subprocess paste killed by signal (Broken pipe) Errors were encountered while processing: AAA E: Sub-process /usr/bin/dpkg returned an error code (1)
(where AAA,BBB,CCC are placeholder names, in case it wasn’t clear)
do
sudo dpkg -i --force-overwrite AAA
(give full path of AAA), and then run
sudo apt-get -f install
again.
Gnome File Selector
Although there is no indication anywhere, one can actually start typing, and a box will appear to accept your input. This is incredibly unintuitive, but who’s to argue with the folks at GNOME? (Actually, even Gaim has this “feature”—start typing in the buddy list window to see it. So it could be a GTK+ thing, and not a GNOME thing…)
There are actually two places that take input:
- The one that pops up when you start typing the name of a directory, say. This is at the bottom-right corner, and isn’t very good. No autocompletion.
- There’s another one, that pops up when you type Ctrl+l (that’s l for location) or when you start typing with a /. This one has autocompletion, but works a bit weirdly: it interprets each keystroke as occurring after the completion (so if you start typing /etc, it will go into /etc after the ‘e’, then look for files beginning with ‘/etc/t’). Another problem is that it’s not done until you actually type the whole thing. For instance, to open /usr/bin/emacs, it is not enough to type “/u[sr/]b[in/]em[acs]{RET}” — that makes it look for “/usr/bin/em”. You can’t type “/u[sr/]b[in/]em[acs]a…” either: those files don’t exist. The only thing you can do is “/u[sr/]b[in/]em[acs]{Backspace}s{RET}”. Very weird. And if the file you want is inside the home directory, it can be got with “/{Backspace}~/…”.
Also, when “/bin/” or “/usr/bin” has too many files, opening one of them can take quite a long time. A “solution” is to have a separate directory (like “/usr/freqbin”) that contains links to all the programs that one might want to use to open things downloaded from the net (because the File Selector is encountered mostly when using Firefox).
2007-10-26: At some point, it started accepting “~” too, so you don’t have to do “/{Backspace}~” now. The rest of the mess is still there.