## Copy Date/Time to Windows Clipboard with C++

I was unable to find a suitable program to quickly generate a timestamp in the format I desired, so I decided to write one using C++, specifically MinGW’s g++ v4.5.0 along with <windows.h>. This is my first real experience with Windows-specific programming other than a few hello worlds, so it was instructive as well as frustrating. It took considerable time to discover and familiarise myself with SetClipboardData(). Eventually I was able to modify the code in this thread (which didn’t compile as-is) and obtain a working clipboard prototype very similar to this, which I didn’t find until afterward. After that, it was mainly a matter of understanding the functions in <ctime>.

The format I was after is this:

2010-12-20 07:44:19 UTC-5

However, the code can of course be easily modified for various other formats. Here is the code:

## My Love for You Is a Monotonically Increasing…

Just now I ran across a funny question over at Yahoo! Answers on mathematical pick-up lines, and I decided to pick out a few favourites (taken from Y!A and elsewhere):

- My love for you is a monotonically increasing unbounded function. (I think in order to see this as funny you have to imagine somebody saying it
*with feeling*.) - Your beauty cannot be spanned by a finite basis of vectors.
- I donâ€™t like my current girlfriend. Mind if I do a you-substitution?
- I wish I were your problem set, because then I’d be really hard, and you’d be doing me on the desk.

Also worthy of mention:

- Your lab bench, or mine?
- Your mama’s so fat she has a proper subgroup isomorphic to herself.
- I’m a fermata… hold me.

Last but not least, there is this gem:

## Modeling Sequences with Polynomials

Suppose I asked you to find the next term in the sequence

2, 4, 6, 8, 10, …

Of course the expected answer is 12. But then I could tell you that these terms correspond with the formula

so the *actual* sequence has

2, 4, 6, 8, 10, 14, 26, 58, 130, 272, …

This illustrates a common misconception that there is a unique solution to these sorts of problems. In fact, starting with the first five evens, we can pick any real number as the sixth term and find a polynomial of degree at most 5 to model it using some basic linear algebra.

## A Model for Everything

Let f(x) be a function of interest. Then we can find a model ∀x: f(x) ≈ 0 ± G where G is Graham’s number. I think this model will prove useful in many branches of science!

## Yahoo! Deactivation Design Issue

Although I would like to reproduce this behaviour to be sure it wasn’t a fluke, today I discovered what I consider a design flaw in Yahoo!’s automated account deactivation logic. On the one hand, there is an option during login to “Keep me signed in”, which will keep the user signed in indefinitely on that computer and browser until cookies are cleared or the user signs out. On the other hand, there is a policy to deactivate accounts for which the user has not signed in for some set period of time. The problem is that one can be using Yahoo!’s services every day without signing in, and then suddenly discover that the account has been deactivated when signing in on another computer. While my experience with this problem resulted in no data loss, it was still a bit unnerving. What if that archive of emails and contact information going back several years had been lost?

I plan on reporting this to Yahoo! as soon as I can reproduce it to be positive it is a consistent problem.

Web developers beware! If it can happen to a large corporation with vast resources, maybe it could happen to you too.

## Simple Asterisk Pattern with Recursion

Background: I introduced code golf in a previous post.

I recently came across an easy but fun problem posted on Yahoo! Answers. It could make for a good code golf exercise. I will write the problem statement in a purposely vague manner, but clear enough to make the goal obvious; specifics can be added according to any particular contest or testing environment.

Using only recursion and no loops, print a triangular pattern of asterisks according to the following example:

Input:

1 3

Output:

* * ** *** ** *

## Mental Health Point of View

I’ve been somewhat active on Yahoo! Answers recently, and a question came up about someone being depressed and not wanting to take medication, but needing help. I decided to re-post my answer here in case anyone would find it useful. I have not edited it in any way while transferring it from Y!A to WordPress. So, here it is:

I also personally dislike the idea of medications for such problems, although in some extreme cases (for example, having hallucinations that won’t go away) then I think medications are perfectly reasonable. But for non-hallucination type situations, I believe in human spirit to overcome such things!

Of course many will disagree, but I believe this firmly.

To me it boils down to two things: (1) awareness (2) control.

## Reflexive Assignment in Java

Background: Code golf is a game in which the goal is to solve programming problems using as few keystrokes as possible. It has its roots in Perl golf, and anyone with golfing experience knows that Perl is particularly well suited to such challenges. J and K, as well as the more esoteric GolfScript, are also known for combining terse syntax with powerful features. Obfuscation is a related topic.

In this post, I will discuss a snippet of Java code one might not normally think to write. I understand that “Java code golf” is practically an oxymoron, since it seems the goal of Java is to write code using as *many* keystrokes as possible, but let us overlook this point for now.

Suppose we want to increment a variable by an integer from standard input, but only if that integer is positive. We could use this code fragment:

## Happy 10-10-10 Day

Not that I set much store by such things. Why no movie 10 to complement the two movies 9 and Nine last year?

## Microwave Design

This is how a microwave should work: If you press 2, then 3, then 5, then start, it should start counting down from 2:35 while heating your food. Pressing the number 2 should *not* make the microwave automatically start counting down from 2:00. Whoever designed such microwaves should be forced to [censored by internet monkeys] while a gang of midgets [censored by internet monkeys] by a unicorn with [censored by internet monkeys] helplessly and [censored by internet monkeys] just for good measure.