Programming

...now browsing by category

 

Drupal 6 Social Networking

Saturday, April 18th, 2009
Drupal 6 Social Networking is one of the lastest publications addressing the use of the popular open source content management framework.

Drupal 6 Social Networking is one of the lastest publications addressing the use of the popular open source content management framework.

I’ve fought it for a long enough time, but I’m finally taming my dislike of Drupal.  I’ll admit - its mostly because I’m now using it for what it is - a framework and not as a content management system.  Now I seem to be growing as a Drupler.  Fast-foward to a few weeks back: I was browsing about Amazon and came across Drupal 6 Social Networking.  After reading the entire book in a few days, I felt it deserved a review.

Drupal 6 Social Networking is written to reach a wide audience - from programmers to content administrators, no matter the level of experience.  It is authored by Michael Peacock of Peacock-Carter, a web developer from Newcastle, UK.

The book is broken down into 10 chapters, ranging from an introduction to drupal and social networks, installing drupal, using the framework to create the functionality desired, and even into web site promotion.

The highlights of this book is that is an easy read and is written for those that are not exactly sure of what certain features relate to in the system.  For example, have you ever wondered what the full use of Taxonomy is in Drupal?  Peacock has a casual writing style that gets directly to the point, accompanying his writing with on-point visual examples to add visual detail to his writing.

If you are new to the Drupal framework, this book will guide you from installation to project setup.  If you are seasoned with the framework, but not exactly sure how to make the best of specific modules to get the performance / functionality you need, this book will enlighten you with which module to use and why to use it.

Overall, this is a worthy purchase that gets directly to what the title states - drupal 6 and social networking.  This mean, you guessed it, Michael directly focuses on how drupal can be used to build a social network and he doesn’t slide off topic in doing so.

For those interested:

Simple Javascript to Combat Spam

Monday, August 25th, 2008

Before you read any further, take into context this isn’t going to fully help you in terms of lessening your spam. However, it is a neat trick and will help some, or at least deter some spamming bots from picking your e-mail address and using it for spam.

While at work today I was performing some maintenance on a project that was handed to me and I noticed a tiny bit of javascript used to print an e-mail address, but by doing so kept it seperate and not connected.

<script type="text/javascript">
    emailE=('roberthash@' + 'yahoo.com')
    document.write('<A href="mailto:' + emailE + '">' + emailE + '</a>')
</script>

What you see first is that a variable is assigned two values that are added together. By splitting the e-mail into two pieces (in theory), this will assist in deterring spam bots searching for a valid e-mail address.

emailE=('roberthash@' + 'yahoo.com')

From there we utilize the document.write() function to print this text to the browser window.

document.write('<A href="mailto:' + emailE + '">' + emailE + '</a>')

Another beautiful part is that if Javascript is not installed, this means there won’t be an e-mail address showcased. However, this could be a pain if you have someone trying to find your e-mail address that has a legit reason to contact you - but doesn’t have Javascript.

As usual, it is a method to be used at your own risk or if you feel it is indeed the solution for your project.

With further research, I have found the origination of this code, which can be found at http://www.joemaller.com/js-mailer.shtml.

As you can see - it is a very simple approach that even a novice programmer can understand. Who says you can’t learn new tricks?

Populating TextBox with Date via C#

Friday, August 22nd, 2008

I have found through my web application development experience that it can be quite the pain if someone messes up a date. This is a huge headache for reporting purposes.

Methods to get around this can be one of many things. Validation for example simply forces the user to put in a date before they can submit information. Who is to say they are putting in the right date anyway? The ASP.NET calendar control is nice, as it gives a calendar and allows the user to pick a date. One method that I have found to work quite nicely for data that is entered for a day is to have the date set automatically.

What would be a scenario for this? The ideal setting is to track a date when an action is committed. Examples include form submission (no-brainer), requests, updates, etc.

For example, let’s say we have the following form:

<form runat="server">
  <asp:Textbox ID="dateBox" runat="server"></asp:TextBox>
</form>

Now, using the code behind file, we can write a simple line of code to send today’s date straight to the dateBox ASP Textbox upon the loading of the form.

With an aspx file, in the code-behind we can add an attribute to the Page_Load method to autopopulate a date (or set any value - same premise). Below we will set it within an IF statement for when the page posts back:

protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
{
  // This will happen upon a postback
  dateBox.Text =DateTime.Today.ToString("MM/dd/yyyy");
}

Or you can set the value in outside of the PostBack IF statement:

  dateBox.Text = DateTime.Today.ToString("MM/dd/yyyy");

As you can see, that simple line of code will send today’s date straight to the textbox without the user having to enter it. We have included it in the page load portion to see that it fires upon, as you guessed it, the loading of the page/form. To break it down further, we can add some pretty neat attributes to the code to produce other effects:

If we want to add tomorrow’s date, we can use .AddDays(+1)

  DateTime.Today.AddDays(+1).ToString("MM/dd/yyyy");

If we want to add yesterday, we can use .AddDays(-1)

  DateTime.Today.AddDays(-1).ToString("MM/dd/yyyy");

Want to populate a year? You can use the same premise. As Nico VanHaaster has pointed out, you can call the AddYears() method to combat leap year occurances:

  DateTime.Today.AddYears(-1).ToString("MM/dd/yyyy");

As one can see, it’s a very simple approach to solving a problem with user’s entering a date and becoming frustrated if they have to do this more than once (such as they enter this data after each task on a given day).

Happy Programming!

Dynamically Populating a DropDownList with C#

Wednesday, August 20th, 2008

Okay, out of fairness I thought I would post the same tutorial for my favorite dynamic duo - ASP.NET and C#. We will assume we are using the same database name or table name. We will work with a asp:DropDownList control such as:


<asp:DropDownList id="state" runat="server"></asp:DropDownList>

We will create a method called StateDropDown:

private void StateDropDown()
{
}

From there we will define our connection settings - typically what we have set in the web.config file.

SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["MySettings"].ConnectionString);

From there, much like the PHP example, we will create an SQL query that will scope the database table to populate the dropdown. We will assume i’m connecting to a database named info and a table named state.

string Sql = "SELECT * FROM info..state";

Now for the fun of C# - creating a dataset, filling the dataset, then applying that dataset to your asp:dropdown control.

SqlDataAdapter sqlAdapter = new SqlDataAdapter(Sql, Con);
DataSet ds = new DataSet();
sqlDA.Fill(ds);
state.DataSource = ds.Tables[0];
state.DataTextField = "state_abbr";
state.DataValueField = "state_id";
state.DataBind();
}

And now for the unmolested code:

private void StateDropDown()
{
//Define your connection
SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["MySettings"].ConnectionString);
//Create your SQL query/string
string Sql = "SELECT * FROM info..state";
SqlDataAdapter sqlAdapter = new SqlDataAdapter(Sql, Con);
DataSet ds = new DataSet();
sqlDA.Fill(ds);
//Define which control will accept this dataset
state.DataSource = ds.Tables[0];
state.DataTextField = "state_abbr";
state.DataValueField = "state_id";
//Bind the dataset to the control
state.DataBind();
}

VT Rampage Game Questions Taste and Freedom of Speech

Tuesday, May 22nd, 2007


I might be on an edge by even giving this attention, my input, or other media coverage. I do feel though this is an important subject and I would like for those of you to read through this blog before making any judgements at all.

I was scoping Newgrounds.com today and I ran across a game that really caught my attention. Unfortunately, the game itself isn’t one I’d recommend to others. It seems as though someone has tried to exploit the events of April 16th at Virginia Tech (just a mere 12 minutes from my home in Radford) through a video game entitled simply “VT Rampage”.

At first my thoughts were simple - How could anyone be this tasteless?

So then I played the game. The creator literally programmed a flash game to “relive” the events. You are Cho, the relentless psychopath that looks to send a message to the world. Your first mission through the 1st stage is to shoot Emily Hilscher - the first victim in the actual events. Events then move on as you return to the dorm to film the manifesto tape. From there Cho must “stealthily” make it past a ward of police to drop the package off to the Post Office. From there is where “the fun begins”, as the creator puts it in Cho’s words.

Norris Hall is nothing more than a glorified bloodfest. You have a time limit to slaughter as many students as possible, even with a theme song playing in the background encouraging “Go Cho Go!”

At the end of the time limit, with 32 dead and various injured, Cho is left with only one choice - to take this life. The game ends there, with credits rolling in shortly afterwards.

Personally I am all for freedom of speech. What I am not for however is the right for people to be so distasteful. It is an outrage that this online game portrays the events, let alone NAMES one of the victims in the game and allows you to murder her. This is truly a lack of respect towards the victim!

With further research I see that the media has really picked this up and has even conducted an interview with the game’s creator - Ryan Lambourn. Turns out he’s a 21-year-old living in Australia, but grew up in the United States (credit - MSNBC). With that being said, Ryan should be able to connect since most of those killed were students HIS age. So why would someone still do such a thing?

It has also been stated that he will remove the game if the government pays him a price. Should the government fold and pay the “ransom”? How does this play into freedom of speech and freedom of the Internet?

Frankly, if the government pays to have the game removed, it will create a few scenarios in my opinion.

  • By paying the ransom, you open the gateways for similar games. Oklahoma City Rampage anyone? So what will the government do then? Pay to have each game removed?
  • By taking the game off, it takes away some of the freedom of the Internet. Should legislation be passed to limit what can be posted on the Internet? Who will be the judge of what is tasteful, politically correct, and eligible to be posted?

Either way, Ryan is getting exactly what he wants. He’s getting cheap press and has become highlight of chat through various media, including this blog. What he has done on the bright side has screwed any chance he had at becoming a respected professional in his field of work, let alone a respected human being.

Incase you’re interested, this video game can be found at www.newgrounds.com

What? My Program Works?

Monday, May 21st, 2007

I gotta say, the ability to understand programming pays off. After getting fed up with the time I was wasting logging into Ta-Da List I decided to write my own listing program.

I like to look at it as a list management system.

I really didn’t need to be super organized, such as organizing by day, week, etc. I created the list just how I would create my own sticky notes - random, jot some info down with a title and post it. The program works just the same - I have an idea, I click my bookmark, the web application comes up and I’m ready to go. Add a title, a little descriptive information and wah-la! It’s posted. I can even edit the list if I screw something up and I can delete it once the task/list/whatever is completed.

I’m still thinking about releasing it once I complete the interface to meet my tastes. Will it be open source? Most likely!

PHP and MySQL are a great marriage. What are some of the applications some of you guys are building to meet your needs?

Aptana Reviewed

Thursday, May 17th, 2007
As I stated in an earlier post, I have come across an open source IDE known as Aptana. It is directed towards javascript and AJAX which has recently become a huge interest of mine and other developers.

I gotta say I was impressed from the initial startup of the program. Immediately (although it is cluttered) the program opens with a wide variety of tools and options to assist you in your project.

Not much is left to wonder as it has on screen modules/tools for:

  • Validation
  • IE & Firefox Preview
  • Rails Support
  • Code Assistance (major plus!!)
  • File navigation
  • DOM Navigation is amazing and very detailed
  • On the fly updates when changes are made

The libraries included with Aptana are large and quite impressive to say the least. From what I see, there are plenty of tools for you to include in your projects, ranging from element fading effects to element positioning and even Flash related scripts.

Although I’ve only been using it for a day or so it has already shown that it is a powerful IDE. I have read that Aptana can be imported into Eclipse, which should provide a better base for JAVA and PHP programmers. Don’t waste anytime, go to www.aptana.com and download this tool. It will definitely make your life a lot easier as a programmer.

Drawing a Blank

Tuesday, May 15th, 2007

I tend to find myself as one confident individual - unless math is involved. I personally have a weird way of finding solutions (they work.. just not how its schemed to be solved). Also - when it comes to programming I can’t exactly write down the correct syntax as well as I can type it out. Something about the comfort of a keyboard I suppose…

Point being, I found this recently when giving a programming and logic test. I highly recommend testing yourself and keeping sharp with brain teasers and some programming basics. When given the test I found myself drawing blanks on many questions that I KNEW the correct answers for. I also found myself literally stumped on how to correctly write syntax on various items I knew how to program.

Does anyone else have this problem at all sometimes?

Final Exam of the Year

Friday, May 4th, 2007

Well, this week has been enough to say the least. Now, in a mere 40 minutes I will take my American Literature final exam. WHOO!

As for other news I will be interviewing with Webmail.us next week. I really hope this turns out well.

Also - out of boredom I scripted my own to-do list. Granted, Ta-da List already does this.. and I do use that quite a lot. The issue that popped out at me was that I personally didn’t always have time to boot up firefox and login to Ta-Da. Now, with my own little program I can boot it from my desktop via a flash interface and add away :). I will most likely post the code in the next few weeks once I touch up the visual pieces.

I will be out of town until Sunday night/ early Monday morning to visit family. If you need to reach me try the cell phone or e-mail.

Wish my luck, I’m off!