.net 3d art blog c# coding college computers editorial entertainment firefox food freeware gaming hardware hdtp hiking humor ide japan japan, javascript linux mac mailbox milestone misc. mods momoiwa, mono movie nintendo philosophy php politics rant rebun review science software technology time ucr wakkanai windows work wormholeftp
An ominous title, for yet another, but this time rather technical, guest post by EER.
Today I'll talk a bit about some crazy stuff I have been developing for work lately. As you may or may not know, I primarily work with .Net. Our government in the Netherlands is slowly moving to 'alternative' software platforms such as Linux or Macintosh.
Now Linux is not much of a problem, it is a developers' platform, and being a developer, I feel right at home using Debian or Ubuntu. But a macintosh is a whole different story. Luckily, I found the terminal after about two hours fiddling and everything is semi-normal if you just use the terminal ;)
Armed with a terminal and the latest version of the Mono framework I went about and tried to run my app. Of course, this failed horribly and I considered various options to get it all running. My first experiments with Windows Forms interfaces on the mac weren't very successful (to say the least). After inquiring on the mono-winforms mailing list, I was told to use the native Mac OS X driver by exporting the following variables from the terminal:
export MONO_MWF_USE_QUARTZ_BACKEND=1
export MONO_MWF_USE_CARBON_BACKEND=1
That looked a bit better than the X11 version, but still the stability was crap. So I moved on to check out the native Mac OS X interface programming framework "Cocoa". There are bindings available for Mono: cocoa#. These bindings are distributed with mono on mac by default.
So I tried to use them, which did not work as I came to expect from .Net when programming Windows Forms. So finally I'm coming to a point: Mac programming is different. How different you ask? I'll give you some hints to get started more easily:
Code samples can be found in the Cocoa# source code, but I'll explain some of the attributes you can use:
[Register("ControllerClass")] // You can use the Register attribute on a class to register it with the Object you have defined in the Interface Builder.
[Connect] // Use the Connect attribute to link the public class variable to one of the outlets defined on the registered object in the Interface builder. These outlets can also be linked in the Interface Builder to various components in your NIB. For this to work, your object needs to be delegate for the component you want to access here.
public Cocoa.Panel aboutPanel;
[Export("show_about:")] // You can use the Export attribute to link class functions to the functions defined on the registered object. These functions will then execute managed code when they are called from the UI.
public void show_about(Cocoa.Object sender)
[Export("applicationWillTerminate:")] // The last one, still an Export, but this is the one you will need for cleanup code. As the Messageloop does not return, this is the event handler if the application is terminated by pressing Quit in the dock. For this to work, the registered object should be delegate for the application.
public void ApplicationWillTerminate(Cocoa.Notification not)
I'd heard about Search Engine Optimization (SEO) before, but I'd never really thought about applying it to this blog. SEO aids search engine crawlers in indexing the content on your site by offering up more information into URL's than you'd normally get using integers to call up certain posts. Before today, when you clicked on a link to comment on a post, you'd be taken to a url that looked like this:
http://unleashedcreativity.net/comments.php?post=140
To a search engine, this post reveals nothing about the contents of post #140. If someone tried to look for this post by its title, they'd have to know the exact title and hope that it was the first result that popped up when they performed a search. SEO works for bloggers by making it easier for viewers to find content.
Case in point: Now, when you want to see post #140, you'll see a link that looks like this:
http://unleashedcreativity.net/comment/140/Build_a_site_in_24_hours_Yes_says_the_ man_in_the_blogosphere.html
As a viewer, you're more likely to remember the fact that I used "blogosphere" in the title of that post than you would the fact that you were reading post #140. In the future, you'll be able to search for "Unleashed Creativity blogosphere" and find that post at the top of the list instead of whatever post featured the most occurrences of that word!
I feel bad waiting until now to mention his name, but I wouldn't have been able to get the blog up to SEO standards without some gentle prodding and help from EER. We just finished spending two and a half hours working mod_rewrite into the system, making sure that any link to a comment page was in SEO-format, devising a means for me to link to previous posts through FCKEditor, and optimizing the search-by-tags functionality. It went off very well, all things considered; we ran into a fair share of problems, but between the two of us we were able to make everything play nicely.
I'd get a bit more technical in this post, but my brain is fried and I'm about two and a half hours behind on my reading for the week. EER is waiting on the wings and will post about an as-of-yet-unknown topic in the next day or two, so stay tuned for that; provided he doesn't talk about all the work we did today, I'll be back after him to explain some of the techniques we used to revitalize UC!
During my travails around the interwebs, I came across an interesting Digg article. It turns out someone managed to get a website up and online, from scratch, in 24 hours. The 24 hours were spread out over 4 days, but it was still an impressive feat to go from mock-up to development to production in such a short amount of time.
To get the site up and running as quickly as he did, he relied on Ruby on Rails for the site's framework, as well as some free SVN to keep track of changes to the site files (a technique I plan on looking into implementing in the next day or two).
Graphically, the site isn't too complicated, but he admitted himself he's not much of a CSS buff; he basically took a template he designed in Photoshop and sliced it up into easy-to-manage template images. It's an admirable approach, but I know I can do better since I'm quite good at CSS!
I also have to give props to the guy for developing a fairly robust API within the 24-hour time slot. It appears to be fairly painless to use and offers a degree of interactivity that you wouldn't expect from a quickly-launched website.
Needless to say, Dominiek's endeavor got me thinking. I've been sitting on a novel website idea for the last four months or so, and I've decided that it's time I brushed the dust off and resumed work. I have a lot of ground to cover if I plan on launching any time soon, but I think if I tackle it in small chunks, it'll all come together relatively quickly. I'll start to reveal details of my mystery project as they're fleshed out, so stay tuned!
And I need more readers! Perhaps when I get my new project off the ground I'll develop some readers. I've only had a few "tech-related" postings, and I've done squat for SEO or marketing, so I can understand why my blog has basically tanked. I suppose there's always a chance my new project will take off and I'll gain a loyal following, but I'm sure that's something time will have to determine!
Until next time, folks!
I finally figured out a round-about way of disabling FKCEditor plugins based on the page the editor is being used on. As I mentioned earlier, I installed an autosave function that will preserve my new posts until I post them onto the front page; the problem I was having was that if I wanted to edit an existing post, the AutoSave would save that post's content over the saved new-post's content. What I needed to do was disable the auto-save script on the Edit Post page.
It turned out to be a fairly easy solution. Basically, I grab a GET variable related to the current page's function from the page's URL and load the AutoSave only when that variable is set to a specific value. On any other page (i.e. the Edit Post page), the auto-saver is not loaded. In the case of this blog, it was a rather small bit of code:
var windowCode = parent.window.location.href.split('specific_GET_variable=')[1] .split("&")[0]; //(multi-lined because it broke the layout) if(windowCode == 1) { //Load Plugin }
I have to call parent.window because FCKEditor is loaded into a frame. I also learned that if I want to grab the current page's URL as a string, I need to call window.location.href as opposed to simply calling window.location; window.location is an object, and it contains much more information than just the URL. After grabbing the URL, I split the string into an array using the GET variable I want to read as the point where I want the string divided into separate array elements. Then, I perform another split on the second element of the first array. The second split is performed to single out any other GET variables that may appear in the page's URL. I can then grab the value of the desired GET variable, which is stored in the first array element of the second split.
It's a simple yet elegant solution, if I do say so myself :P
I have to laugh hysterically to myself every time I even think about writing something new on UC. I laugh not because I've lost my sanity, but because I realize that I have very little information to benefit others. I wrack my brain trying to think up a decent, interesting topic and pull up nothing; after all, how interesting is an 8am-5pm job, Mondays through Fridays, and a weekend spent playing games or browsing the internet? I don't even like reading about it, and I live it!
Today's a little different, though. I managed to find a bit of code from my most recent project that I thought might help others should they come across the same problem as me.
What problem am I talking about? Why, the problem of finding a decent way to convert RGB color strings to Hexadecimal color strings!
I needed a function that could read color strings given by a browser and return those colors as Hex if the browser returned RGB. It took a bit of searching and piece-mealing, but I managed to come up with a function that gets the job done, and here it is:
function RGBtoHex(rgb)
{
if(rgb.search(/#/) > -1)
{
return rgb;
}
else
{
rgb = rgb.substr(4, rgb.length - 5);
rgb = rgb.split(", ");
r = parseInt(rgb[0]).toString(16).toUpperCase();
g = parseInt(rgb[1]).toString(16).toUpperCase();
b = parseInt(rgb[2]).toString(16).toUpperCase();
if(r.length == 1) { r = "0"+r; }
if(g.length == 1) { g = "0"+g; }
if(b.length == 1) { b = "0"+b; }
return "#"+r+g+b;
}
}
The function itself is pretty simple to use; send a color string (either "rgb(r, g, b)" or "#XXXXXX") to the function RGBtoHex and you will get back a hex string. Hex strings are automatically detected and returned; the true magic happens when you send an RGB string through.
First, the function removes the "rgb()" from the string. Then, an array is created that houses the Red, Green, and Blue values.
From there, each number is parsed into its appropriate Hex value via toString(16), then uppercased to match Hexadecimal formatting. If only one character is returned during this process (for example, if Red equals 0 before being converted to Hex, it will return "0"), then the string requires a zero (0) in front of it.
Finally, the function takes the three parts of the RGB string, lines them up in order, and places a pound sign in front of it, and voila! A Hexadecimal string from an RGB string!
This is the cleanest I could make the code (sans taking out all the line breaks), and in fact this is the second version of the original function; I find that over time, all my functions get refined, and this one was no exception!
I've got a large web-based project that I'm working on in my free time, and though it still has a while before it is ready to be released, stay tuned; I'll be sure to drop a link here when everything is ready to go!
Until next time, ladies and gents!
Every once in a while, I'll see some article on Digg about programming font alternatives and I'll find myself thinking, "is that really necessary?" I've been around programming for the last four or five years, and in all that time I've never once moved away from the default Windows IDE font.
For those of you who've never touched programming in a computer language, most programming integrated development environments (IDE) are set to use the monospaced Courier New font. Created in 1955 for typewriters, this font eventually found its way into Windows operating systems as far back as Windows 95. The strength in this font and many of the other monospaced fonts is that the characters all line up vertically. Here's an example of what I'm talking about:

I've compared Courier New to Times New Roman because TNR is widely known as a popular font for word processors. As you can see from the guide lines in the image, all the characters typed in Courier New (the monospaced font) line up, while the characters typed in Times New Roman do not. A benefit to monospacing characters in code is that its possible to easily compare the content of various lines of code. If I want to compare a MySQL database connection string from one file to a similar string in another file, I can just copy-paste the two strings and compare their string length to check for any inconsistencies or differences between the two. With a font like Courier New you'll notices character differences between strings almost immediately.
Since I started coding, I've tried to switch fonts once or twice. I stayed away from TrueType fonts because I liked the look of monospaced characters, but finding a monospaced font I like was difficult. Every time I tried a different font, I thought the text was too small or the characters were too blocky. SOME monospaced fonts even boasted a special tiny size, as though I liked coding at size five font. No matter which font I tried, though, I ALWAYS moved back to Courier New. Call it stubborness, call it security, but I had found my favorite programming font a long time ago.
I suppose the perfect programming font is determined solely by personal preference. Personal experience tells me that, for a word document, non-monotype-fonts such as TNR are perfect because they set up words that look more naturally-spaced, similar to how someone would write. When it comes down to programming, monospace fonts are the way to go because of how neat the code looks easy it is to compare various bits of code. Just my two cents.