Sunday, August 23, 2009

This is truely frightining!

Apparently New Jersey is batshit and so is this judge.  How can "no person shall be deprived of the inestimable privilege of worshiping Almighty God" possibly be part of a state constitution? It's so completely out of line with the Bill of Rights.

Beyond that I call into question the judgment of Mr. Camarata. How can the religious/anti-religious views of the parent be considered to "deprive" the child of her "privilege" to worship "Almighty God"? At worst this clause prevents the parents from from forbidding their daughter from worshiping "Almighty God", or otherwise preventing her from doing so.

Hopefully the Burkes win their appeal and Mr. Camarata gets disbarred for gross incompetence.  

Blog Conversion

I just converted www.madscienceguild.org from a bluehost+wordpress blog to a blogger blog! I didn't feel like paying to renew hosting with bluehost, so I decided to just move it over. The process was pretty simple once I found wordpress2blogger.appspot.com which allows you to convert your wordpress export xml files directly to blogger export files which can then be imported into blogger. Huzah!

Thursday, August 6, 2009

git - One command to rule them all.

I have only recently learned the joy that is git. For the longest time I thought "SVN works for me why learn a new version control system." Well, as cliche as is sound, you don't know what your missing until you've used it. Two things really impress me with git, the ease of branching and the ability to "commit changes" to a local repo without "push"ing them to the main repo. These two features really put git significantly above Subversion.

Needles to say, after seeing the light and deciding that git is the way, I wanted to migrate one of my subversion projects to git. So I googled "converting svn to git" and found quite a few answers out there. The OS X solution was:

port uninstall git-core
port install git-core +svn

and...
git-svn clone SUBVERSION REPO

However after running the uninstall and reinstall no magical git-svn command showed up. This frustrated me to no end for the better part of an hour. Until I found a blog post that informed me that git had spiffied up the git tools. The new syntax is apparently:
git svn BLAH BLAH BLAH

So essentially a series of 'git-*' commands have all been distilled down into the main 'git' command, which is really neat. Less executables to clutter up tab completion lists, and one stop shopping for all your git needs. I think this is really important so let me repeat it, commands like "git-svn" have for the most part been replaced with "git svn". Spread the word.


Wednesday, July 8, 2009

Stupid Google Trick 01

So Google is being awesome and stupid at the same time. They have made gmail accounts openids, well sorta. It's just that no one accepts '@gmail.com' as an openid since that's not in the specs.

If you want to actually be able to use your gmail account as an openid go to http://openid-provider.appspot.com/ and follow the instructions there.

Fuck you google, why can't you just provide `http://gmail.com/openid/` for full compatibility with standards.

Monday, June 8, 2009

PHP is a messy hack.

So I'm building a php site for a client from scratch.... I know I know I should be using a framework of some sort. However I don't want to bill my client for learning Cake or what have you. Anyway I decided to implement (a simple version at least) Rails' "flash" functionality for the site. If you're unfamiliar with Rails' flash, its basically a kick ass way to pass data from one page to another.

You put a message such as "Thanks for signing up!" Into the flash and then redirect the user to their new account page (or whatever) then as long as the account page is setup to display "flash" messages, It will show you message and then remove it from the flash. This is really handy for displaying one time messages without sending the user to a basically useless page.

So I cooked up this:

// Make sure sessions are active.
session_name("campaign63");
session_start() or die("session failed to start");

// Displays and clears flash data
function display_flash()
{
//Check for and display flashes
if(isset($_SESSION['flash_notice']))
{
echo '
' . $_SESSION['flash_notice'] . "
\n";
unset($_SESSION['flash_notice']);
}
if(isset($_SESSION['flash_warn']))
{
echo '
' . $_SESSION['flash_warn'] . "
\n";
unset($_SESSION['flash_warn']);
}
}



Then all I need to do is run the following in the page I want the flash to show up in:

require_once"flash.inc.php";

and...

display_flash();

Where I want the flash to show up. And here is where things get messy. So the next step is redirecting users to a page setup to display the flash. The standard way of redirecting with PHP is:

header("Location: URL");

Which is a horrible hack and only works if header info hasn't already been sent. I thought I could work around it so I started pasting it all over my existing pages. Turns out that it worked some of the time but not all the time, and it seemed totally random to me.

Luckily for me I'm working on a VPS from Rimu hosting which means that I have root access to a virtual server for $20 per month! So I found http_redirect in the pecl_http package. Installed PECL and then installed pecl_http. I replaced all instances of `header("Location: Url");` with `http_redirect("page.php");" and now my flashes work just fine!

Lesson learned, PHP does not work out of the box. It is simply broken. The pecl_http library rocks! Don't get hosting from a provider who doesn't support it.

Wednesday, May 27, 2009

Stupid BASH Trick 01

I have to look this up all the time, if you are BASH scripting and you want to do something with each file in the current directory try something like this:
#!/bin/bash
for i in $( ls ); do
echo item: $i
done

Or the one liner
for i in $( ls ); do echo item: $i; done
There, maybe next time I will not have to look as hard. :-P

Vbulletin Can go to Hell

Just so that I don't forget to say "HELLLL NO!" next time someone asks me to work on a vbulletin site. I'm going to post my reasoning here:
  1. The community sucks! Whenever I want to learn how to do something "outside the box" with Vbulletin I start with a google search, this invariable leads me to a "forum post" that generally says "go to vbulletin.org" no link to a relevant help article or piece of doccumentation, just vbulleting.org. That would be fine if vbulletin.org was useful. But it's not, its just a vbulletin forum that you can only read the helpful info if your are a registered user.
  2. Apparently the people at vbulletin have never heard of an API the closest thing they have is a user contributed hack from two years ago which doesn't fully work with the latest version of vbulletin.
  3. Its community supported pay-ware. WTF!?! So the interactive support comes in the form of a forum powered by users, and I have to pay for access? That's bullshit!
In summary vbulletin is a steaming pile. Also, there are plenty of other forum solutions out there that are free as in beer as well as open source. I bet they don't make you pay for access to their community supported documention/support. Grrr.

Wednesday, May 20, 2009

Atheism Rocks

The Out Campaign: Scarlet Letter of Atheism
s a matter of fact, atheism is the position supported by science, logic, and rational free though. Yet somehow conservative religious fundamentalists have convinced the general populous that we atheists are 'sinful' and 'evil'.

I for one, am tired of being persecuted for my lack of faith and desire for evidence. The god hypothesis just doesn't make any sense. Richard Dawkins does an excellent job at showing just how unlikely a god of any kind is in his book The God Delusion. Dawkins is much more eloquent than I, so don't take my word for it, read a real "good book" and think about it.

If you are already an atheist. I challenge you to be open and honest about it, and spread the word. Closet atheists do the rest of us no favors. People need to know that atheists make up a significant portion of the worlds population. Atheists are mothers, and brothers, friends, and colleagues, and above all people.

If you have a blog or website of your own, out yourself!

Tuesday, May 19, 2009

Custom Titles in Rails

One thing I've learned while building rails sites is that changing things in the header on a view-by-view basis can be tricky. This starts becoming important when you start optimizing your page for Google. One thing Google likes is descriptive and non-repetitive title tags. To get view by view customized title tags try this.
  1. Add `<%= yield(:title) || "Default Title" %>` to your layout inside your title tag.
  2. Add `<% content_for(:title, "Custom Title") %> to your view file.
You can replace "Custom Title" with code such as `@object.name` or anything else that returns a string for even more dynamic titles. I've had to look this technique up more than once now so I'm blogging it in an effort to better remember it. I hope it is useful to you as well. You can use this technique to put other things in the header as well just use `yield` and `content_for` judiciously.