Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Friday, July 30, 2010

mingw and gcc

If you want to use API calls you need to do two things:

- include the right header file so C/C++ knows the function prototypes for the calls, and the types and structures that they use as parameters
- link in the right library file (.a files in .\lib), which I'm guessing contains the object code that actually implements the calls. There appears to be a 1:1 .a file/.dll file correspondence.

Eg to use GetDeviceCaps in gdi32.dll, you need to include wingdi.h and link to libgdi32.a by adding -lgdi32 to your gcc invocation.

If you're just calling stuff from user32.dll (definitions in windows.h) you don't seem to need to say -luser32. Looking into this further with the very helpful -v compiler switch, I see that gcc links to the following libraries by default

-lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt

Indeed I see that it does this for the simplest hello.c program, even without windows.h being included. That's not a complaint, I just want to know how it is.

mingw linking

Suppose mygdiprog.cpp includes wingdi.h and uses various API calls implemented via gdi32.dll

g++ -lgdi32 mygdiprog.cpp

will throw up errors for the API calls along the lines of 'undefined reference to GetDeviceCaps@8''.

You must place -lgdi32 (which means 'link in stuff from lib\libgdi32.a') after the source file name

g++ mygdiprog.cpp -lgdi32

(This is why -mwindows makes it work, because -mwindows adds a load of -l options, and it puts them in the right place on the command line.)

Tuesday, July 27, 2010

Javascript Date

Javascript Dates appear to adjust themselves automatically for (US) daylight savings time. Eg

dateInTheDSTPeriod - dateBeforeTheDSTPeriod

will not be a round number of days if both dates represent midnight (because Javascript thinks that by 'midnight' on dateInTheDSTPeriod you mean 0000 BST, 2300 GMT).

Often with astronomy you mean 0000 GMT in the above example, and your date calculations will be an hour off. Get round this by using the ..UTC... versions of all relevant Date methods.

Incidentally, you can add n days to a Date by doing setDate(d.getDate() + n) . I don't know if there's any limit to n but it certainly works up to 366 days.

(Yes, getDate means 'getDayOfMonth', so we are adding n days to the day of month).

NBB A Date is an object: if you assign d2=d1, d2 is the same object as d1, and if d1's properties change, so will d2's, and vice versa. Bit annoyed with myself for not realising that tbh.
The way to shallow copy is d2 = new Date( d1.valueOf() ) .

Monday, July 19, 2010

.CUE files and burnatonce

To start referring to a new source file, simply add another FILE line. Track numbering should continue in sequence (not start again from 01).

Don't forget that for after each FILE line, you probably want a track with INDEX 01 00:00:00 . It's easy to miss it out and start with the position of the 2nd track.

The time fields are mm:ss:cc (cc being hundredths, not 'frames').

burnatonce seems to expect TITLE lines - with the title in quotes - both for tracks and the disc as a whole. Specify "" if necessary.

burnatonce doesn't object to the omission of AUDIO after TRACK nn.

burnatonce will not process files with tabs. Use spaces to indent.

burnatonce uses the actual size of the audio files specified, if your CUE file mistakenly contains a track that starts beyond the end of the file then that track is ignored.

burnatonce occasionally thinks a file is slightly longer than it is - seems to happen when the file is a fraction of a second shorter than an integer number of minutes, eg 26:59.68 . It will then put up an "0 MB to be written to disc" message box when Write is clicked. If you answer OK the log will contain a complaint that it's trying to go past the end of the file. The way to fix this is to right-click the last track of the offending file in Audio Mastering, choose Properties and make the length slightly shorter - 0.01 second is often enough, but if it isn't, try slightly larger reductions till burnatonce accepts it.

Javascript substring

String.substring(n1, n2) is not like typical substring functions - firstly, n2 is a character index, not a length, and secondly, it's the index of the first character not to include in the substring.

Both indexes are 0-based btw.

Tuesday, July 13, 2010

In the context of Google Spreadsheet timed triggers, the active sheet is the one that the script is part of. It doesn't matter whether it's open at the time the trigger runs.

Friday, July 9, 2010

Javascript reminders

Array length is in length (not Length or Count) and it is a property, not a method.

for (v in a) { } loops through the property names of a - if a is an array, each value of v is an element index, eg 0,1,2... , because array elements are basically object properties.

If you want the element values, which is what you'd expect coming from Perl, say, use a numeric loop, or this construction

for (v in a) { do_something( a[v] ); }

String indexing starts at character position 0.

Thursday, July 8, 2010

Getting rid of the Title in Sharepoint lists

1. Go into (list)/General Settings/Advanced Settings
2. Set 'Allow management of content types?' to Yes
3. Back on the Customise page, a Content Types list is now visible. Click on the Item item.
4. Click on Title
5. Set Column Settings to Hidden.
6. Go back to Go into Customise/General Settings/Advanced Settings and set ''Allow management of content types?' back to No
7. Title will now not appear when list items are edited.
8. But it will still show on the Default View until you modify the latter to hide it.
9. You will probably also want to add the 'Edit' dummy column to the default view in column 1, if like me you're used to clicking Title to edit list items.
10. You can also add the 'ID' column to the default view if you aren't using your own unique identifier.

http://social.technet.microsoft.com/Forums/en/sharepointgeneral/thread/89042dd1-1960-4eaa-91c6-8a6d0ddab1a3, scroll down to JadeSerys' post

Friday, July 2, 2010

.NET system tray icons

//in form definition
NotifyIcon tray = new NotifyIcon();

//in constructor (after InitializeComponent [sic])
tray.Icon = new Icon("myiconfileinexecdir.ico");

//when you want to show it
tray.Visible = true;
tray.Text = "This text appears as a tooltip when mouse hovers over icon";

//hide it again
tray.Visible = false;

//to accept clicks on the icon
//
tray.Click += new System.EventHandler(tray_Click);
...
void tray_Click(object sender, System.EventArgs e) {
...
}

//to make the icon disappear immediately the form closes, set tray.Icon to null on closure

Thursday, July 1, 2010

sqlite dates

To get sqlite to parse a date string, including 'now', you have to use date() or datetime(). There is no automatic conversion.

sqlite is very particular about dates. This will work

date('1963-11-23')

but this won't

date('1963/11/23')

Also NB that datetime('10:21:00') will not default to today's date, but to Jan 1 2000.

And further NB that to subtract (etc) dates you must use julianday() to convert them to numeric values. Your difference will thus be in fractional days.

Incidentally they are proper Julian Day numbers which is handy for astronomy.


So let's be clear, datetime() converts a string to a standard format datetime representation string. It is these strings that are stored in datetime type fields.

Conversely, julianday() converts these strings into serial date numbers (specifically Julian Day numbers).

Followers

Blog Archive