Installing Cassandra on Ubuntu Linux
January 11, 2010
Categories: IT & Administration, Web & Software Development
Tags: Cassandra, NoSQL
Cassandra is a highly scalable, eventually consistent, distributed, structured key-value store. It’s an alternative to SQL if you don’t need relational data structures. The best part is it’s super fast, and distributed. The worst part is there’s not much documentation or community, at least compared to MySQL. So, I’m doing my small part to contribute to Cassandra. Here’s how I installed Cassandra on Ubuntu 8.04.2 LTS (hardy), but these directions should work on pretty much any Linux distro.
1. First upgrade your software as is with the following two commands (just for good measure):
sudo apt-get update sudo apt-get upgrade
2. Now, open up your Debian package sources list with Nano for editing using the following command:
sudo nano /etc/apt/sources.list
3. Next, add the following sources to your /etc/apt/sources.list file.
deb http://www.apache.org/dist/incubator/cassandra/debian unstable main deb-src http://www.apache.org/dist/incubator/cassandra/debian unstable main
After you add these two lines, press cntrl+X to close Nano. It’ll ask “Save modified buffer?” Press Y. Press Enter when Nano asks “File Name to Write.”
4. Run the update to install Casandra with this command:
sudo apt-get update
5. ERROR! At this point you receive an error similar to this:
W: GPG error: http://www.apache.org unstable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F758CE318D77295D
6. Use the following three commands to ignore the signature error, and continue installing:
NOTE: You must replace the key value ‘F758CE318D77295D’ with the key value you received in your error message.
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys F758CE318D77295D sudo apt-key add ~/.gnupg/pubring.gpg sudo apt-get update
7. Install Cassandra:
sudo apt-get install cassandra
8. Next you need to change Cassandra’s default port number from 8080 to something else, because the 8080 port typically conflicts with SSH terminal connections. Use Nano to open up the Cassandra configuration file using the following command:
sudo nano /usr/share/cassandra/cassandra.in.sh
9. Then change the port number 8080 on the following line to 10036, and save the file:
-Dcom.sun.management.jmxremote.port=10036 \
10. Start Cassandra with the command:
/etc/init.d/cassandra start
Once you have Cassandra running, test it with Cassandra’s command line tool CLI. Use the example found on the Cassandra Wiki.
How to Update Ubuntu Hardy to PHP 5.2.9
April 24, 2009
Categories: IT & Administration, Web & Software Development
Tags: Linux, PHP, Ubuntu
First upgrade your software as is.
>> sudo apt-get update
>> sudo apt-get upgrade
Then add the following to your /etc/apt/sources.list file.
>> sudo nano /etc/apt/sources.list
deb http://http.us.debian.org/debian stable all deb http://security.debian.org/ stable/updates main contrib deb http://packages.dotdeb.org/ stable all
Finally
run the update to install PHP 5.2.9.
>> sudo apt-get update
>> sudo apt-get install php5-cli
>> sudo /etc/init.d/apache2 restart
Global page navigation accross WordPress MU blogs
January 29, 2009
Categories: Web & Software Development
Tags: Wordpress, WordPress MU
Here’s the scenario. You have a WordPress MU site with multiple blogs, but for whatever reason, you want every blog to have the same main navigation and pages. Your main site/blog hosts all of your pages. So how do you go about creating a WordPress MU Theme that will use the navigation and pages from your main site/blog accross all of your blogs? Well, I’m here to tell you how I did it.
The WordPress Codex has a function called ‘wp_list_pages.’ What I wanted to do is create a new function called ‘wp_list_main_pages.’ So I simply searched my WordPress install and copied the ‘get_pages’ and ‘wp_list_pages’ functions and pasted them into my theme’s ‘functions.php’ file. From here I made a few edits to these functions. To start with, I renamed them ‘wp_list_main_pages’ and ‘get_main_pages.’
Below is the final code I’m using to display the main navigation accross blogs. I made notes in bold to help. Hope this is helpful to you Googling coders.
// You can use this function instead of 'wp_list_pages' in your theme
function wp_list_main_pages($args = '') {
$defaults = array(
'depth' => 0, 'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0, 'exclude' => '',
'title_li' => __('Pages'), 'echo' => 1,
'authors' => '', 'sort_column' => 'menu_order, post_title'
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$output = '';
$current_page = 0;
// sanitize, mostly to keep spaces out
$r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
// Allow plugins to filter an array of excluded pages
$r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));
// Query pages.
$r['hierarchical'] = 0;
// Right here we call our new 'get_main_pages' function
$pages = get_main_pages($r);
if ( !empty($pages) ) {
if ( $r['title_li'] )
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
global $wp_query;
if ( is_page() || $wp_query->is_posts_page )
$current_page = $wp_query->get_queried_object_id();
$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
if ( $r['title_li'] )
$output .= '</ul></li>';
}
$output = apply_filters('wp_list_pages', $output);
// This line is sloppy and needs improvement.
// You have to remove the name of the blog your currently on from you global navigation.
// I'm doing this the simplest but least scalable way here.
$output = str_replace("pressroom/", "", $output);
if ( $r['echo'] )
echo $output;
else
return $output;
}
// This is essentially a private function
function &get_main_pages($args = '') {
global $wpdb;
// This is the magic line.
// Now when the SQL runs to pull your navigation pages, it'll use your main blogs ID.
$wpdb->set_blog_id(1);
// Notice here I call the original get_pages function and return the results
$pages = get_pages($args);
return $pages;
}
ASP.Net US States Dropdown List
May 14, 2008
Categories: Web & Software Development
Tags: ASP.Net
For large projects I usually databind my dropdown lists, but sometimes you just need a no-nonsense dropdown list of US States. For all you folks Googling to save time, here’s that code. Enjoy!
<asp:DropDownList ID="DropDownListState" runat="server"> <asp:ListItem Value="AL">Alabama</asp:ListItem> <asp:ListItem Value="AK">Alaska</asp:ListItem> <asp:ListItem Value="AZ">Arizona</asp:ListItem> <asp:ListItem Value="AR">Arkansas</asp:ListItem> <asp:ListItem Value="CA">California</asp:ListItem> <asp:ListItem Value="CO">Colorado</asp:ListItem> <asp:ListItem Value="CT">Connecticut</asp:ListItem> <asp:ListItem Value="DC">District of Columbia</asp:ListItem> <asp:ListItem Value="DE">Delaware</asp:ListItem> <asp:ListItem Value="FL">Florida</asp:ListItem> <asp:ListItem Value="GA">Georgia</asp:ListItem> <asp:ListItem Value="HI">Hawaii</asp:ListItem> <asp:ListItem Value="ID">Idaho</asp:ListItem> <asp:ListItem Value="IL">Illinois</asp:ListItem> <asp:ListItem Value="IN">Indiana</asp:ListItem> <asp:ListItem Value="IA">Iowa</asp:ListItem> <asp:ListItem Value="KS">Kansas</asp:ListItem> <asp:ListItem Value="KY">Kentucky</asp:ListItem> <asp:ListItem Value="LA">Louisiana</asp:ListItem> <asp:ListItem Value="ME">Maine</asp:ListItem> <asp:ListItem Value="MD">Maryland</asp:ListItem> <asp:ListItem Value="MA">Massachusetts</asp:ListItem> <asp:ListItem Value="MI">Michigan</asp:ListItem> <asp:ListItem Value="MN">Minnesota</asp:ListItem> <asp:ListItem Value="MS">Mississippi</asp:ListItem> <asp:ListItem Value="MO">Missouri</asp:ListItem> <asp:ListItem Value="MT">Montana</asp:ListItem> <asp:ListItem Value="NE">Nebraska</asp:ListItem> <asp:ListItem Value="NV">Nevada</asp:ListItem> <asp:ListItem Value="NH">New Hampshire</asp:ListItem> <asp:ListItem Value="NJ">New Jersey</asp:ListItem> <asp:ListItem Value="NM">New Mexico</asp:ListItem> <asp:ListItem Value="NY">New York</asp:ListItem> <asp:ListItem Value="NC">North Carolina</asp:ListItem> <asp:ListItem Value="ND">North Dakota</asp:ListItem> <asp:ListItem Value="OH">Ohio</asp:ListItem> <asp:ListItem Value="OK">Oklahoma</asp:ListItem> <asp:ListItem Value="OR">Oregon</asp:ListItem> <asp:ListItem Value="PA">Pennsylvania</asp:ListItem> <asp:ListItem Value="RI">Rhode Island</asp:ListItem> <asp:ListItem Value="SC">South Carolina</asp:ListItem> <asp:ListItem Value="SD">South Dakota</asp:ListItem> <asp:ListItem Value="TN">Tennessee</asp:ListItem> <asp:ListItem Value="TX">Texas</asp:ListItem> <asp:ListItem Value="UT">Utah</asp:ListItem> <asp:ListItem Value="VT">Vermont</asp:ListItem> <asp:ListItem Value="VA">Virginia</asp:ListItem> <asp:ListItem Value="WA">Washington</asp:ListItem> <asp:ListItem Value="WV">West Virginia</asp:ListItem> <asp:ListItem Value="WI">Wisconsin</asp:ListItem> <asp:ListItem Value="WY">Wyoming</asp:ListItem> </asp:DropDownList>
C# How to get a QueryString value from the UrlReferrer
April 24, 2008
Categories: Web & Software Development
Tags: C#
To get a QueryString value from the previous pages URL (aka: the UrlReferrer) you can use HttpUtility.ParseQueryString.
Like this!
NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(Request.UrlReferrer.Query); string keyword = nameValueCollection["kw"];
“And that’s all I have to say about that.”
