Do you want to execute operating system specific code (exes) in the .NET/Mono framework? I’ll go over how you can do that.
Below is part of a class I had written that can determine if Linux or Windows is running. Keep in mind that for the code to properly detect Mac OS, you will need to figure out the proper platform number and modify the code respectively.
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace namespace1
{
static class HostOS
{
/// <summary>
/// an enumerator that holds a list of possible operating systems
/// this code can execute on
/// </summary>
public enum HostEnviroment
{
Windows,
Linux
}
/// <summary>
/// determine the operating system this program is running on
/// </summary>
/// <returns>the current operating system</returns>
/// <remarks>
/// the current choices are only linux or windows
/// it really only checks to see if the OS is linux,
/// otherwise, it defaults to windows
/// if other OS are inplemented in the future, this
/// would need to be changed
/// </remarks>
public static HostEnviroment determineHostEnviroment()
{
HostEnviroment currentHost;
int platformNumber = (int)Environment.OSVersion.Platform;
//determine if the host is a *nix operating system
//these numbers take into account historic values,
//do an internet search for details
if ((platformNumber == 4) || (platformNumber == 6)
|| (platformNumber == 128))
{
//running on *nix
currentHost = HostEnviroment.Linux;
}
else
{
//not running on *nix (this function defaults to windows)
currentHost = HostEnviroment.Windows;
}
return currentHost;
}
//............
}
}
I had written this class because I have been writing code that I develop on Windows, but needs to run in Linux. Ideally, I wanted it to work in both operating systems for various reasons. The program I was writing needed to call a few console applications that were operating system specific, but had versions for both Windows and Linux. Thanks to the System.Diagnostics namespace, it’s quite easy to run the OS specific code!
Adding extra vertical space (eg. carriage return) to postings in WordPress can be a pain. While there might be a plugin to fix the issue, learned by searching around that using the code:
<br class="blank" />
When in HTML mode will not be deleted by the visual mode processor. So if you flip back and forth between the two input modes, that code appears to be safe from being removed.
Here are a few tips to securing a wordpress based blog or site:
Change the location of your wp-content directory. This is good for making your site’s source code less discernable as a wordpress blog.
In the wp-config.php file:
define( ‘WP_CONTENT_DIR’, $_SERVER['DOCUMENT_ROOT'] . ‘/wp-content’ );
define( ‘WP_CONTENT_URL’, ‘http://example/wp-content’);
Change “wp-content” to something else.
Keep in mind that some plugins are not programmed correctly and have hard-coded links to the content directory as “wp-content”, so that could cause issues. If you notice your plugins not working, open the related source files and search for the phrase.
————————–
Change the admin’s login name to something besides “admin”
This can be done with something like phpMyAdmin to edit the database.
The user_login varchar(60) field in the wp_users table is the value you want to change.
You should be able to leave the user_nicename and display_name alone.
————————–
Password protect your wp-admin folder on the server using CPanel (you will have to login twice, but adds a second layer of security).
————————–
Modify your .htaccess file in the index directory to disallow access to wp-config.php
<files wp-config.php> Order deny,allow deny from all </files>
Lately, I’ve been interested in the benefits of having a dedicated source control server.
My goals for the project:
1. Have a dedicated server to store source and other files I’m working on that could benefit from source control and a secondary backup.
2. Have the server accessible through the Internet so that friends who I am working with can access our projects.
3. The server should be as low power usage as possible.
4. Attempt to make the server as secure as possible. Probably only have one port directed to it (either the http webdav or svnserve protocols on a custom port). I might also consider having ssh directed as well so I can use something like NoMachine NX Remote Access.
Last weekend I ordered an “MSI Wind PC” computer to take on that role. This computer is sold as a barebones unit that doesn’t come with RAM or a hard disk. For about $220 total, I was able to get an ATOM based computer with a 750GB Western Digital hard drive and 1GB of ram. The main benefit of this setup should be the low power usage which I estimate to be around 25 – 35 watts. Checking an online energy cost calculator it said the device should cost around $40 a year to power (24hr a day), which isn’t bad!
This week I’ve been learning more about Subversion. I have installed a basic install of Ubuntu desktop in a Sun Virtual Box virtual machine and went through (this great Ubuntu document) to get up and running.
I also Installed The Eclipse PDT IDE (PHP) and the Subeclipse SVN add-on
Using the basic Webdav setup, I easily linked Eclipse with the repository in my virtual machine. Here is a tip with the virtual machine: Setup your network adapter as a “Bridged Adapter.” What will happen is that the VM will talk with your router directly and get its own IP address completely separate from your host OS. This way, it’s east for your host OS to talk with the VM through the network.