I use this code here.
backgroundImage = (Bitmap)Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\images\Header.jpg");
backgroundGraphics = Graphics.FromImage(backgroundImage);
var font = new Font("Perpetua Titling MT", 24F, FontStyle.Regular);
backgroundGraphics.DrawString(authorname.ToUpper(), font, new SolidBrush(Color.FromArgb(100, 0, 0, 0)), 10, 5);
Now save – or output to the browser:
If you use Response.Redirect to direct users to a new location, you should be aware that it issues a status code of 302, which means that “the resource resides temporarily under a different URI.” If you intend to communicate that the resource has permanently changed locations, you should not use Response.Redirect. This is important for search engines and other crawlers that might need to know the definitive url.
To send a 301 redirect:
Response.Status = "301 Moved Permanently";
Response.StatusCode = 301;
Update: ASP.Net 4.0 ads a Response.RedirectPermanent() method.
The following PHP script updates missing post slugs (permalinks) in a WordPress blogs, or reformats them according to your needs:
Continue reading “Bulk update post slugs in a WordPress blog” »
While trying to migrate a large blog from Movable Type to WordPress, I found the built-in export and import functionality unable to handle volume of content on the blog or to properly preserve the primary keys needed for permalinks.
With assistance from Alvaro on the MisesDev list, we came up with the following MySql SQL script to import the entries directly from the Movable Type (5.01) database to WordPress (2.9.2). What would take many hours otherwise can be done in a minute or two. This is especially important if you don’t want to lose data during the time it takes to migrate the blog, as the script can be run immediately before the switch. This script also includes additional stuff like IP addresses and url-friendly names.
Continue reading “SQL script to migrate from Movable Type to WordPress” »
To open an app in terminal, type open -a AppName or open /Applications/AppName.app if you want to specify the path. I use it for starting VNC server via SSH.
Bonus: echo “set completion-ignore-case On” > ~/.inputrc will make auto-completion case-insensitive.
When processing photos, sometimes you want to re-orient the photo according the orientation recorded by the camera (such as the iPhone’s accelerometer) and stored in the EXIF meta data. It’s easy to do:
// Rotate the image according to EXIF data
var bmp = new Bitmap(pathToImageFile);
var exif = new EXIFextractor(ref bmp, "n"); // get source from http://www.codeproject.com/KB/graphics/exifextractor.aspx?fid=207371
if (exif["Orientation"] != null)
RotateFlipType flip = OrientationToFlipType(exif["Orientation"].ToString());
if (flip != RotateFlipType.RotateNoneFlipNone) // don't flip of orientation is correct
exif.setTag(0x112, "1"); // Optional: reset orientation tag
// Match the orientation code to the correct rotation:
private static RotateFlipType OrientationToFlipType(string orientation)
1: In IIS7 manager, enable dynamic and static compriession. (This adds <urlCompression doStaticCompression=”true” doDynamicCompression=”true” /> to applicationHost.config)
2: Open C:WindowsSystem32InetsrvConfigapplicationHost.config and go to the httpCompression section. For both dynamicTypes and staticTypes: <mimetype=”*/*” enabled=”true”>
3: Run appcmd in %systemroot%system32inetsrv
appcmd set config /section:httpCompression /[name=’gzip’].dynamicsCompressionLevel:10
appcmd set config /section:httpCompression /[name=’gzip’].staticCompressionLevel:10
(Set the value to 7,8,or 9 for less CPU usage)
Note: compressing static files prevents them from displaying incrementally while the rest of the file downloads in the background. This may be useful for viewing partially loaded PDF’s, text files, images, etc. It may be appropriate to enable/disable compression per-directory in some cases.
More information on IIS7 HTTP compression.