DropCash COM Object

Here’s something you might find handy: as a C# programming project, I made a donationware-based Windows Component Library for DropCash. Details are at the page. Basically, if you’d like to integrate a DropCash campaign into your existing .NET codebase, this makes it about as easy as can be.

Here’s the DropCash campaign that i’m running along with this project. If it hits my goal, i’ll open source (license undecided) the COM Object so that people can make their own interface styles.

Apache/PHP: $_FILES Array mysteriously empty

Frustrating moment of the day:

A file upload form that’s been working for a long time, suddenly fails. No file uploads work on the entire apache installation. Checking the drive space in the /tmp folder, even though 85MB are left, freeing up space reveals that if there isn’t a lot of free space left for /tmp, the $_FILES array just goes empty without further explanation. No useful error messages, or anything.

Freeing up space for /tmp solves the problem effectively.

Update: Since so many commenters have posted other problems that cause similar effects, here is a quick summary of potential issues that you should check:

  1. Check php.ini for file_uploads = On, post_max_size, and upload_max_file_size. Make sure you’re editing the correct php.ini – use phpinfo() to verify your settings. Make sure you don’t mispell the directives as 8MB instead of the expected 8M!
  2. Make sure your FORM tag has the enctype="multipart/form-data" attribute. No other tag will work, it has to be your FORM tag. Double check that multipart/form-data is surrounded by STRAIGHT QUOTES, not smart quotes pasted in from Word OR from a website blog (WordPress converts straight quotes to angle quotes!). If you have multiple forms on the page, make sure they both have this attribute. Type them in manually, or try straight single quotes typed in manually.
  3. Do not use javascript to disable your form file input field on form submission!

  4. Make sure your directory has read+write permissions set for the tmp and upload directories.
  5. Make sure your FORM tag has method="POST". GET requests do not support multipart/form-data uploads.
  6. Make sure your file destination and tmp/upload directories do not have spaces in them.
  7. Make sure all FORMs on your page have /FORM close tags.
  8. Make sure your file input tag has a NAME attribute. An ID attribute is NOT sufficient! ID attributes are for use in the DOM, not for POST payloads.

Coding Model-View in C# – Accessor Notes

Thanks to a suggestion by Greg Knauss, i’ve learned how to split a Windows Component Library into frontend and backend, with namespaces for each. Here are some notes about my process:

  1. Different Views (User Controls) should each have a private variable equivalent to your Model (backend Class) class.

  2. To propagate Accessor method settings that you might be able to modify when adding components onto a test form, you should use the get{} and set{} accessors that show up when adding a component as Misc properties. These should modify local View private properties. Then, in the View Class’s Load method, you can call a constructor of the backend with these private values, which should be set by the time you hit the Load method. Note that you can’t do this in the constructor of the View Class itself, which i’m sure is a technicality due to class startups and instantiation order that i’m just not familiar with in C#.

  3. By providing your backend with public properties via accessors, it simplifies your life when building varied frontends, because you can access backend properties at any time with your View’s copy of the backend class.

Tuning and Optimizing MySQL Applications

Having run across a couple very fascinating leads on query/index tuning, i’m listing here the steps i’m taking to do so myself.

  1. Get a hint that you have slow queries. status on the mysql command line produces: …..

Threads: 31 Questions: 1850200 Slow queries: 16 Opens: 1268 Flush tables: 1 Open tables: 64 Queries per second avg: 10.706

  1. Add the following (or similar) to your my.cnf:

Gordon 20041001: Changed longquerytime to 5s

set-variable = longquerytime=5 logslowqueries = /var/log/mysql/mysqlslowqueries.log

Log queries that don’t use indexes

loglongformat NOTE: If you put a space anywhere in longquerytime=5, it will cause the server to fail.

  1. Make sure that the mysql slow queries log is writable by your mysql daemon user.

  2. Restart MySQL. It might be helpful to tail your error log to check for errors during restart.

  3. Your slow queries log should now be created in the directory you specified. Verify it exists, and tail it while you run your application.

– I’ll update this later with additional analysis tips.

References: http://dev.mysql.com/doc/mysql/en/Slowquerylog.html – MySQL Manual Reference http://databasejournal.com/features/mysql/article.php/2013631 – Article http://retards.org/projects/mysql/ – Perl slow query log parser