mds (MacOS spotlight indexing) was always running, and constantly thrashing. I believe this is happening because it's trying to index remotely mounted drives (which are enormous). The solution is a program called mdutil
sudo mdutil -v -a -i off # turn indexing "-i off" for "-a" all volumes (-v verbose)
sudo mdutil -v -i on / # turn indexing "-i on" for the volume / (-v verbose)
A repository of notes; by noto, for noto. Made public so noto can read it from anywhere. It won't make any sense to you.
Tuesday, August 17, 2010
Tuesday, April 27, 2010
Command shortcuts in vim (vi)
I was tired of looking this up every time, so I add this line to my ~/.vimrc file:
Now in VIM, I type “:html” to create a new .html file with syntax highlighting
:cnoreabbr html runtime! syntax/2html.vim
Now in VIM, I type “:html” to create a new .html file with syntax highlighting
Tuesday, April 20, 2010
Comparing strings without regard to case
I couldn't find a C++/STL built-in comparison function for strings without regard to case. I really thought there would be one, but apparently not.
So here's one for example.
So here's one for example.
// Compare two strings without regard to alphabetic case
int stricmp(const char *a, const char *b) {
static const int offset = 'a' - 'A';
for (; *a && *b; a++,b++) {
if (*a != *b) {
char la = 'A' <= *a && *a <= 'Z' ? *a+offset : *a;
char lb = 'A' <= *b && *b <= 'Z' ? *b+offset : *b;
int diff = la - lb;
if (diff) { return diff; }
}
}
return *a ? 1 : *b ? -1 : 0;
}
// Compare two pointers-to-strings without regard to alphabetic case
int sorting_stricmp( const void *a, const void *b ) {
const char **s1 = (const char **)a;
const char **s2 = (const char **)b;
return stricmp(*s1,*s2);
}
// Compare two C++ strings without regard to alphabetic case
int string_icmp(const string &s1, const string &s2) {
return stricmp(s1.c_str(), s2.c_str());
}
Labels:
C,
C++,
case,
ignore case,
lower,
standard template library,
STL,
upper
Monday, April 12, 2010
Random Numbers in R
The key is set.seed( <seed value> );
Then you can use runif(n=<number of values>, <min>, <max>)
to get random reals, or sample(x, size, replace = FALSE, prob = NULL)
to get a random sample from a collection.
Tuesday, March 16, 2010
Adding alternate-row shading to your LaTeX Tables
Two steps,
- In the preamble:
\documentclass{article}
\usepackage[table]{xcolor}
\definecolor{tableShade1}{HTML}{F1F5FA}
\definecolor{tableShade2}{HTML}{ECF3FE}
\begin{document} - Just before \begin{tabular}, add
\rowcolors{1}{tableShade1}{tableShade2}
The first argument is which row to start on. This is useful (e.g.) if your header row is actually multiple rows.
Source: http://www.cv-templates.info/2009/07/alternate-row-shading-latex/
Sunday, January 17, 2010
Creating a Ringtone for your iPhone from an MP3 using Garage Band
This uses Garage Band, which comes with Mac OS's.
- Open Garage Band, create a new project
- (You can delete the piano track by selecting it and then choosing Track → Delete Track from the Menu.)
- Drag your .mp3 file from Finder to Garage Band. This creates a new Garage Band track.
- (I sometimes need to click and drag the track off to the left so it starts at time zero.)
- Play the track and find the start/stop portion you want. This must be less than 30 seconds (If it is slightly more, you can shrink it down later, but this will affect the sound quality a bit.)
- Drag the end of the track (a colored box showing the volume of each portion of the audio--probably two lines for stereo) to the beginning and end of your portion.
- You can zoom in with the logscale slider in the lower-left corner
- You can double-click the track to see a larger version at the bottom of the screen
- You can zoom in with the logscale slider in the lower-left corner
- From the menu, choose Track → Show master track
- Click on the master track to create points near the beginning and end of the track, and move the appropriate points down to fade the volume in and out.
- Adjust the master volume (far right of the play controls) if necessary
- If you need to, you can speed up or slow down your music with the following proceedure (source):
- Drag your audio file (MP3, M4A, ...) in GarageBand. It's shown as an orange track.
- Press Ctrl+Alt+G
- Click the audio track. It is now blue [Ed: purple]
- Check "Follow Tempo & Pitch" (this is in the wave editor section, which you get by clicking the scissors symbol next to the eye) [Ed: This is already open if you double-clicked the track earlier]
- Now change the tempo (next to the song time display) [Ed: Actually click the "tempo" number in the time display window]
- Drag your audio file (MP3, M4A, ...) in GarageBand. It's shown as an orange track.
- Save your file. From the menu, choose Share → Export Song to Disk and save as an .m4a file.
- Rename the .m4a file to .m4r (I had to do this in a terminal)
- Import your .m4r file to iTunes, it shows up under the Ringtones category (in iTunes 8, at least)
- Update the track info if you like
- Sync with your iPhone
Subscribe to:
Posts (Atom)