Incongruity

Comment posted by macemoneta over at Slashdot: “The problem for many people is the incongruity between how they were raised and reality. People are generally raised to believe that people are good, that there are norms of behavior, there is justice in the world, authority figures can be trusted, things happen for reason and are overseen by an omnipotent deity. As we grow up, we learn that these are simply convenient lies that define our society.

When presented with conflicting visual evidence, we can be shocked and damaged – our world view is broken. Some go into denial (classifying the content as depravity), and some go into depression (recognizing that society is simply a veneer). Education and experience over time tends to break these falsehoods more gently, incrementally.”

Capital One: The capital of bad web development?

I discovered a few days ago that my Visa credit card from Capital One had expired but I never got a new card in the mail. I finally got around today to signing in online to request a new card. I saw that I could create a custom personalized card with the image of my choice on it. Clicking on this feature popped up a new window (tsk tsk) for me to begin the process. I accidently closed this evil popup at one point and thought I could just start over creating a card. WRONG! Apparantly their system is so poorly coded that once you begin you can’t start over for THREE HOURS.

Oops…
We’re sorry but it looks like you have recently visited the Image Card site. Please close this browser window and return to the original.

If you’ve already closed the original window, you will need to wait 3 hours before returning to the Image Card site. We’re sorry for the inconvenience.

Dear Capital One: It’s 2010.

Disable post revisions in WordPress 3.0

I recently had a customer that had ~70,000 revisions on posts on his WordPress site. This caused his database to skyrocket to 400mb+. I discovered the cause of these revisions to be the plugin FeedWordpress. FeedWordPress was triggering WordPress to create massive amounts of revisions. Because of this the plugin I wrote, BackupBuddy, could not back up his site without running into PHP timeout issues. In this post is the solution I used to resolve this problem.

In the root directory of your WordPress installation, open wp-config.php in a text editor and insert the following line on a new line somewhere between the top ( looks like ) lines of the file:

define('WP_POST_REVISIONS', false);

Running the following SQL (change wp_ to your prefix) in phpmyadmin will clear out all revisions:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

Finally, run the following SQL query to optimize (clean up) your posts table:

OPTIMIZE TABLE wp_posts;

Return URL at cursor position in textarea

One of the requested features for Typity.com was the ability to navigate links in the textarea without having to highlight, copy, and paste them into the user’s browser URL input. I thought it would be simple to code some javascript to parse the URL around the cursor’s position. I was sadly mistaken. The methods and properties for textarea are a ridiculous mess and very non-standard. After a ton of trial and error, Googling for hours, and reading tons of documentation, I was able to piece together the following code. Keep in mind that I am very new to javascript. This could probably be done much better and may have bugs though it seems to be working fine so far. It seems as if absolutely no one has been able to get this to work before so I figured I should share it with the rest of the internet.

View source code with tabs and spacing intact [typity.com].

/*
* MicroSwift graburl() (C) Copyright 2009 MicroSwift.com. All Rights Reserved.
* Created exclusively for use on Typity.com by Dustin Bolton
* Leave these top 3 lines if using this on your own site or editing, please.
*
* Last updated: 7/17/09. Now works in FF & Internet Explorer.
*
* EXAMPLES:
* graburl(textareaobject)
* Returns the url found touching the user’s current cursor position.
* User may have to click first in the area sometimes. Not sure of a workaround
* Only tested in firefox so far!
* I hate textarea javascript… textarea is designed so poorly and inconsistent.
*
*/

function graburl(o) {
if (o.setSelectionRange) {
o.focus();
caret=o.selectionStart; // Set initial caret position when clicked.

// Find beginning of url
i=caret;
linestart=-1;
while(i>0) {
charcode=o.value.substring(i-1,i).charCodeAt(0);
if ((charcode==10)||(charcode==32)) { // If line feed or space, reached left border
linestart=i;
i=-1; // branch out
}
i=i-1;
}
if (linestart==-1) { linestart=0; } // Hit BOF

// Find end of url
i=caret;
lineend=-1;
while((i0)) {
charcode=o.value.substring(i-1,i).charCodeAt(0);
if ((charcode==10)||(charcode==32)) { // If line feed or space, reached left border
lineend=i-1;
i=-1; // branch out
}
i++;
}
if (lineend==-1) { lineend=o.value.length; } // Hit EOF

url=o.value.substring(linestart,lineend);
} else if (o.createTextRange) { // Internet Explorer
r=o.createTextRange();
r.moveToPoint(window.event.x, window.event.y);
//r.expand(“character”);
r.moveStart(‘character’,-1);
// Start at cursor and go left until we hit a space or weird character.
i=0;
leftline=”;
done=false;
while( (i>-9999)&&(done==false) ) {
r.moveStart(‘character’,-1); // Step caret left one position (move START first!!!)
r.moveEnd(‘character’,-1); // Step caret left one position
if ( (r.text.charCodeAt(0)==32) || (isNaN(r.text.charCodeAt(0))) ) {
done=true;
} else {
leftline=r.text+leftline;
i=i-1;
}
}
// Move cursor back to original point.
i=i*-1;
r.moveEnd(‘character’,i); // Step caret right one position (move end FIRST!!!)
r.moveStart(‘character’,i); // Step caret right one position
// Start at cursor and go right until we hit a space or weird character.
i=0
rightline=”;
done=false;
while( (i<9999)&&(done==false) ) {
r.moveEnd(‘character’,1); // Step caret right one position (move end first)
r.moveStart(‘character’,1); // Step caret right one position
if ( (r.text.charCodeAt(0)==32) || (isNaN(r.text.charCodeAt(0))) ) {
done=true;
} else {
rightline=rightline+r.text;
i++;
}
}
url=(leftline+rightline);
}
// url=suspected url. Check it for http and stuff…
if ( (url.substring(0,7).toLowerCase()==’http://’) || (url.substring(0,8).toLowerCase()==’https://’) || (url.substring(0,5).toLowerCase()==’ftp://’) ) {
return url;
} else {
return ‘error’;
}
}

Pastor goes on defense over supposed anti-republican Facebook status

I have been shocked by the beliefs and ignorance of church leaders many times (though no longer surprised) throughout the years.  Organized religion seems to be a breeding ground of fear, hate, and ignorance; though one may argue that these are willful attributes and they are only hiding their beliefs behind their religion for use as justification.  It’s certain that not everyone involved in the church are like this, but unfortunately a great number are.  This is why so much of the rest of the world is so shocked by many of the beliefs held by many in our country.  Much of it just doesn’t make logical sense.  It’s like much of the country is now propelled and driven by emotion and ignorance rather than logic and sound thinking and the church is part of the driving force behind this.

About a year ago I ‘friended’ the youth group leader on Facebook from the church I went to several years ago.  Today I posted the following to Twitter which was mirrored to my Facebook status.

In case you haven’t read about the RNC 2004 mass arrests of peaceful protesters (not an isolated incident)… http://www.2600.com/rnc2004/

The youth group leader, which I later learned is now the pastor of the church, made this reply:

And it’s obtuse willfully ignorant posts like this one that has helped me make the decision to remove you from my friend list. You just keep on acting like republicans have a monopoly on questionable behavior. What about the Black Panthers “patroling the polls” in 2008? How about the ACORN wingnuts and their general lack of regard for the law? … See MoreMaybe you should look into the kkk’s roots in the democratic party and their stated goal to appose the encroachment of blacks Jews Catholics the GOP and other such “undesirables.” To act like either party is innocent of injustices is willfully ignorant. Goodbye and enjoy your trip through the arrogance of youth.

Dustin Bolton – Software Engineer, Web & WordPress Developer