Salient Digital Techno Blog

Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • How to fix WordPress wp-admin htpasswd redirect loop

    Posted on August 6th, 2014 phpguru No comments

    If you want a quick and easy way to boost the security of your WordPress blogs, a simple, fast and easy thing you can do is to place a password on your wp-admin directory. CPanel enables this in a moment, just by going to the “Password Protect Directories” feature within CPanel.

    Password protecting directories works following these simple steps.

    1. Click Password Protect Directories
    2. Navigate to public_html by clicking on the folder ICON
    3. Click the folder name link (NOT the icon) for wp-admin directory
    4. In the dialog, enter a username and password and save the details under the User portion
    5. In the dialog, choose to Enable Protection and give it a name, like ‘Top Secret – No Entry’
    6. Save it and then in another browser tab, navigate to

    Now if you’re like me, your wp-admin is broken with a message, “The page has caused a redirect loop”

    You google something like wp-admin htpasswd redirect loop, and find suggestions how to fix it… and find some blog posts like this or that, but you ask your web host about it, and they don’t let you modify httpd.conf config file.

    What to do?

    It turns out the answer is simple, you just need to edit your .htaccess file and add the following line at the top.

    ErrorDocument 401 default

    If you followed the steps above, the CPanel interface created an .htaccess file for you automatically. Go to the file editor feature within CPanel now, and find this new file inside the wp-admin directory, and click edit. Paste the line at the top, save it, refresh wp-admin, and you should be now seeing a dialog asking for your username and password — the one you set at step 4 above. The final .htaccess file including the password protection we added should look like this when you’re done:

    ErrorDocument 401 default
    AuthType Basic
    AuthName "Top Secret - No Entry"
    AuthUserFile "/home/yourusername/.htpasswds/public_html/wp-admin/passwd"
    require valid-user

    Note, do not edit the path for the AuthUserFile – it will be unique to your account and CPanel configuration. This adds a 2nd layer of protection in front of your wp-admin directory in addition to your existing WordPress administrator username and password.

  • How to fix: The connection has timed out in Firefox 29

    Posted on June 6th, 2014 phpguru No comments

    If your web page dies in 5 minutes, it may not be a server-side issue

    I recently ran into a situation where a long-running webpage would timeout after 5 minutes in Firefox. Every time, with no server logs generated.

    I tried increasing the max_execution_time PHP configuration value with ini_set. That didn’t work. I tried set_time_limit() too, but to no avail.

    After a whole lot of debugging PHP on the server side, I discovered the problem was not related to any timeout on the server configuration. The timeout problem results from a new invisible configuration value that was implemented in Firefox itself at version 29. If you’re running Firefox 28 or before, then there was no such default.

    I tried it in Chrome and things worked fine.

    If you use Firefox, please check your version. If you’re on version 29 then Firefox itself can be the culprit generating a timeout error. You might see, “Sorry, the page could not be displayed.” Try again in a few minutes, check your proxy settings, and so on.

    To fix it:

    1. Quit and restart Firefox so only one tab is open.
    2. Go to about:config (type that into the address bar) and then click OK when you are warned that you are about to void your warranty.
    3. Navigate to the following config key: Network -> http -> request -> timeout
    4. and double click on 300
    5. Change it to a larger value, such as 3600 (1 hour), 7200 (2 hours), or 86400 (24 hours) – the value that works best for your application.

    As you can see, the default timeout in Firefox 29 is 300 seconds, or 5 minutes.

    See the accepted answer on for the gory details.

  • How to split a file into 2 chunks in bash

    Posted on May 9th, 2014 phpguru No comments

    I have a task to take a file with millions of lines, and to split it in exactly two files, with a controlled top `head` portion part A file, and the remainder of the lines in part B file.

    It actually turns out to be somewhat non-trival to split a file in 2 chunks, with a small defined top portion and a large arbitrary bottom portion.

    The split [OPTION]... [INPUT [PREFIX]] function is really designed to make N chunks out of your file, or M chunks each containing N lines; I debated using it and merging all but the first file back together, but decided to look up sed examples instead.

    I ended up with the below function. There’s almost certainly a faster/better way to achieve it but this seems to work.

    Sample usage

    remainderof bigfile.txt 1000
    When that runs you will have this result

    1000_bigfile.txt // this is the top 1000 lines
    1000R_bigfile.txt // this is the remainder of the file after splitting off the top 1000 lines
    bigfile.txt // the original untouched file

    Using optional 3rd argument

    remainderof bigfile.txt 1000 true
    When that runs you will have this result

    1000_bigfile.txt // this is the top 1000 lines
    bigfile.txt // this is the remainder of the file after splitting off the top 1000 lines
    // the original file no longer exists

    Here’s the function

    alias ll='ls -larth'
    function remainderof() {
            if [ ! -z $3 ]
            : # $1 was given
            : # $1 was not given
        if [ $# -lt 2 ]
             echo "Usage: $0 filename_to_split rows_to_chop [opt_bool_process_in_place_destructively]"
             exit 1
        length=$( wc -l < $thefile )
        echo Splitting $batchsize lines off the top of $filename $extension leaving $buffer from $length  ...
        #  The top chunk filename
        # The bottom chunk = remainder of file
        echo "Writing $topfile and $remainder"
        # Split off the first N lines of the file
        head -n $batchsize $thefile > $topfile
        # split off the bottom LENGTH - N lines of the file
        sed "1,${batchsize}d" $thefile > $remainder
        # whether to leave a copy
        if [ "$replaceoriginal" = true ] ; then
            rm -rf $thefile
            mv $remainder $thefile
        echo `wc -l < $topfile` lines in $topfile
        echo `wc -l < $remainder` lines in $remainder
        echo Done

    If you have improvements, leave a comment!

  • how to track multiple svn branches in git

    Posted on March 3rd, 2014 phpguru No comments

    [Note: This mirrored blog post was originally online at If you know Bart, link him here so I can update this citation.]

    I must say that I am no fan of SVN, but SVN and I get a long a lot better since I started using git-svn. Long ago a good friend of mine, Dave O’Neill, taught me how to handle multiple branches using git-svn. I had used that technique until Dave taught me how to do it better.

    Recently I saw this blog post which referenced Dave’s article talking about the first method. I guess Dave never got around to updating his blog with the better way. So I am going to do that here:

    A few of my clients use SVN. Some I am guilty of introducing to SVN. But for this post I need to give you an example that you can follow along with. So let’s use shell-fm — my favorite client — with an SVN repo located at svn://

    NOTE: You should use a modern git release. If git --version is older then 1.5.3, you need to upgrade.

    Let’s start by cloning this repository using git-svn:

        $ git svn clone svn:// -T trunk -b branches -t tags

    NOTE: if you have commit access you may want to modify your svn:// url appropriately.

    UPDATE: --stdlayout is a short form for -T trunk -b branches -t tags, and new versions of git-svn support it.

    This process will take longer then an svn checkout would… a lot longer. There are two reasons for this. (1) you are getting all the history of the project, and (2) SVN has a very slow protocol for this purpose.

    Anyway, once it’s done (it took me about 5 minutes) you will have a directory called shell-fm with the contents of trunk checked out in it. If not for the fact that the .svndirectory is replaced with a .git directory you would have thought that you were using a slower SVN.

    Enter into your new repository and you will see that you have a master branch that is, by default, following trunk.

        $ git branch
        * master

    This is not a git tutorial or a git svn tutorial; but I should at least show how to update your tree, and commit to upstream.

    I would like to insert here an advanced topic of packing your repository. I don’t want to explain it here, see the [man page], but trust me it will make your git experience much more enjoyable if you run the following once in a while:

        $ git gc

    Now, to update your working tree to the latest of the branch you are currently tracking, you would run:

        $ git svn rebase

    This is similar to svn update. There are likely no updates available now, so this will do nothing.

    Next, if you want to share something with the upstream svn server you would run:

        $ vim source/main.c
        $ git commit -m"this is a test" source/main.c
        $ git svn dcommit

    This is similar to svn commit.

    Now, let’s look at these branches I was promising:

        $ git branch -r

    Each of the above is tracking a remote branch in SVN, except for trunk which is tracking trunk. When you run git svn fetch all branches will be updated, and new branches on the remote will be added. git svn fetch fetches the updates with out modifying the local working files (which git svn rebase would). git svn fetch mimics standard git fetch behaviour with an upstream git server.

    Working off remote branches is usually done on local topic branches — that is to say, not on master — but you can use whatever you want as git-svn doesn’t care.

    Let’s thus create a new branch for fixing a mythical bug on the 1.2 branch.

        $ git checkout -b fixing-bad-1.2-bug 1.2

    Almost immediately, and without server interaction, we get a checkout of branch 1.2 contents. You can see where you are with:

        $ git branch
        * fixing-bad-1.2-bug

    If you carefully inspect output of git log you can see that git-svn reveals the branch name and upstream SVN commit ID on the last line of each commit:

        $ git log -1
        commit 308244b0d275db460e3b4527afd51258cece4d33
        Author: strogg <strogg@7df44517-d413-0410-91cf-82ca28b36b55>
        Date:   Thu Sep 13 19:39:51 2007 +0000
            This is a patch from Wisq to make shell-fm accept 302 redirects as well as 301.
            git-svn-id: svn:// 7df44517-d413-0410-91cf-82ca28b36b55

    We are on branches/1.2 commit id 252. If you prefer it, you can even get the svn style log output with git svn log… but why?

    Working on this branch is as easy as working off trunk. You edit, commit, and git svn dcommit to upstream.

    Switching between your local branches is easy…

        $ git checkout -f master
        $ hack hack hack
        $ git commit
        $ git checkout -f fixing-bad-1.2-bug
        # and we're back on 1.2 bug fixing

    Note that you don’t have to push your commits back to upstream immediately, or ever for that matter, to make use of the git repository to store your local changes. But if you do decide to you just need to run git svn dcommit.

    If you’re interesting in migrating CVS to git, have a look at the CVS to git Transition Guide.


  • How to prevent iPhoto launching when connecting iPhone

    Posted on August 25th, 2013 phpguru No comments

    The solution is on the Apple forums:

    1. Plug in your iPhone.
    2. Launch Image Capture from your Applications folder
    3. Select your iPhone once it shows up under devices
    4. Look at the lower bottom pane where you’ll see “Connecting this iPhone opens”
    5. Set this preference to “No application”


    See also: How to prevent iTunes from launching when connecting your iPhone or iPad

  • How to prevent iTunes launching when connecting iPhone

    Posted on August 25th, 2013 phpguru No comments

    The solution is on the Apple forums:

    1. From the iTunes menu at the top go to iTunes>Preferences>Devices>Prevent iPods, iPhones and iPads from syncing automatically.
    2. Check the box at the bottom of that window.
    3. Click on [Your Phone's Button] to access the device. This is on the right side of the iTunes main window toward the top, just to the left of the store button. If you don’t see your phone here, unplug it, plug it in again.
    4. Scroll down and uncheck Automatically Sync when this iPhone is connected
    5. Click Done
    6. Quit iTunes.
    7. Unplug and re-plug in your phone. iTunes should not launch.

    If that doesn’t work, also try:

    1. See if iTunes Helper is in System Preferences > Users & Groups > Login Items
    2. If so, delete it (click it then press the minus button)


    See also: How to prevent iPhoto from launching when you connect your iPhone


  • Speak out while Free Speech is Still Free

    Posted on August 2nd, 2013 phpguru No comments

    You may have seen a bumper sticker that says in bold, red, white and blue letters: “Free Speech Isn’t Free.” This short quote cleverly refers to is the fact that millions of courageous U.S. soldiers over more than two centuries have died, that is, paid with their lives, to protect this inalienable right. The analogy works, so long as you value free speech and understand the history of America.

    Dozens of foreign countries, most notably China, Iran and most Islamist-rule nations have a strict policy prohibiting speech and even ideas opposing the government, its leaders, policies or practices. Just glance for a moment at a few of the Chinese dissidents (paying close attention to how long some of them have been detained) if you need a little help imagining what it might be like living under an oppressive regime lacking first-amendment-type protections.

    Practically anyone who’s made it past the 10th grade should be able to recall that the first amendment to the U.S. Constitution guarantees each citizen’s right to free speech, but how many of us actually exercise it today?

    The full text of the amendment protects more than just speech, but here are the specific parts that apply to free speech:

    Congress shall make no law … abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.

    Clearly, Congress hasn’t passed any law abridging free speech. However, under the soft tyranny of the Obama administration, free speech is just one of many rights being slowly and methodically stripped away from We The People.

    In a recent speech on the House floor, Congressman Jim Bridenstein, gives us a succinct summary of current events:

    “The President’s Attorney General authorized spying on a Fox News journalist, and his family, for reporting on a North Korean nuclear test. The President’s Justice Department confiscated phone records of the Associated Press because they reported on a thwarted terrorist attack. The President’s Treasury Department uses the IRS to target political opposition.

    This doesn’t sound very American, does it? How about another example: who can forget the infamous YouTube video, which Obama himself, Hillary Clinton and Susan Rice all claimed in their worldwide “explanation” tour, was to blame for violence that led to the deaths of four brave Americans, including Ambassador Chris Stevens, in Benghazi, Libya?

    Even though most of us now believe that the video had nothing to do with the attack in Benghazi, the filmmaker who produced it, Nakoula Basseley Nakoula, remains jailed today. Sure, he wrote some bad checks and violated his parole, but many pundits argue that Nakoula is the Benghazi Patsy, and wouldn’t be in jail today if he hadn’t made the video.

    Are we free to upload original videos to YouTube or aren’t we? Doesn’t the first amendment protect Nakoula, along with Fox’s James Rosen and all those AP reporters trying to get their stories published? More importantly, shouldn’t our President be defending these patriots’ voices, instead of trying to squelch them?

    These stories sound more like they originated in Iran or China than most folks would like to admit, but it’s clear to anyone paying attention to conservative news outlets that the bureaucrats in power are now using federal agencies – when and how they please – against American citizens; actions that are largely unprecedented in modern American political times.

    Should we speak out if we disagree with our government? Many of us are afraid to be accused of offensive ideas, or placing our families or employees in a position to be audited.

    In his famous “Give Me Liberty or Give Me Death” speech in 1775, Patrick Henry asked, and then answered, this very question:

    “Should I keep back my opinions at such a time, through fear of giving offense? I should consider myself as guilty of treason towards my country, and of an act of disloyalty toward the majesty of heaven, which I revere above all earthly kings.

    It’s interesting to note Henry’s comment about earthly kings. In many ways, it can be argued that President Obama has crowned himself King of America, and many conservatives point out that his actions amount to thumbing his nose at the Constitution, instead of protecting and upholding it, as his oath of office requires.

    As we watch these elected officials in D.C. trample our Constitution and run roughshod over the Bill of Rights, keep in mind that you have a duty to yourself, to your family, to your neighbors and to all the soldiers who have died before us. Exercise your first amendment right to call out these leaders, whether they be local, state or federal officials, when, in violation of their oaths, their actions don’t hold true to the America our founding fathers imagined.


  • Jodi Arias sentencing trial hung jury: The system isn’t broken

    Posted on May 23rd, 2013 phpguru No comments

    What happened in the Jodi Arias case is a travesty. I think any self-aware person would agree, based on what we’ve seen in the media, but I agree with Clint, a caller to the Mike Broomhead show on 550 KFYI in Phoenix, AZ: Very likely, one juror, maybe two, couldn’t live with themselves, knowing they decided to put someone to death. If just one juror feels it would be wrong to play eye-for-an-eye, and dug in their heels against the other jurors who thought Jodi Arias should be put to death, well, that’s the system we have.

    That doesn’t mean the system is broken. I think the death penalty is warranted in this case, but I don’t know what one or more jurors are thinking, either. It’s a shame for the family that they didn’t just all agree to go with life to end it so we can all get on with our lives.

    Judeo-Christian heritage baked into our justice system ensures that if you’re innocent, (I do not believe Jodi Arias is) that one guy or gal in the jury could be saving your life by preventing your death. I want to continue to believe in the system, even if it appears broken in this instance.

    But I have a question…

    Are Prosecutors allowed to explain to the jury, the cost to the taxpayers of Live vs Death? Does that figure in, or do the jurors have to disregard the cost? I’m guessing they can’t discuss it. The costs shouldn’t affect the jury’s decision, should they?

    Just throwing out some random numbers—let’s say death is a $100k one time fee vs $100k a year for 60 years—the cost to the taxpayer if they give Jodi Arias life.

    That doesn’t seem fair to me.

    We talk about fairness in the media a lot, particularly the so-called MSM, the IRS against Conservatives who have to pay their fair share, for example.

    Why is it the little guy is always on the losing end of that fairness equation?


  • I have to call BULL5H!T on Bing Politics

    Posted on February 24th, 2013 phpguru No comments

    As someone who builds systems to analyze data for a living, I was excited to see Bing encouraging television viewers to take advantage of its real-time political survey at, one of the largest of its kind, during the recent State of the Union address by President Obama.

    I was diligent to take a screenshot of the data being displayed on that night. Now I’m very glad I did. I suspected they may try to fudge the numbers after the fact, and boy, have they ever!

    I’ve seen this kind of data misrepresentation plenty of times in business, but never for political motives, never so obvious, and never using data that was captured and displayed in real time. It’s both embarassing and troubling, but not surprising. It should come as no surprise that even with all the terabytes of data streaming around the internet in every moment, Bing (owned by Microsoft, the same Liberals behind MSNBC) would make such an obvious effort to pad the numbers. But did they really think no one would take a screenshot?

    Take a look below at my adjusted overlay (top) and draw your own conclusions. It looks to me like Bing wants you to believe that sentiment toward the President and his various messages during the #SOTU address were overwhelmingly positive. Nothing could be further from the truth. If you look back at the actual streaming data coming in real time during the address (middle), and compare it to what they’re reporting today, I think you’ll agree: their current portrayal of the data is completely inflated (bottom).

    Why would Bing do this? Could it be that an overwhelming negative response to the president’s bloviating doesn’t fit in with their narrative of how great a job this guy is doing? It just goes to show you, folks, you can’t trust the media to tell you the truth, even when they use real-time data & graphics!

  • What a female near the front lines thinks of women in combat

    Posted on January 27th, 2013 phpguru No comments

    I regret to admit that back in high school I wasn’t that close with my friend, LCC, but over the past few years, I’ve gotten to know her better on Facebook. Today, she’s a lieutenant commander in the United States Navy reserve, and I feel honored to know her. I recently posted on Facebook asking for LCC’s opinions on women in combat in the U.S. military

    Spurred by the recent push by Defense Secretary Leon Panetta to put our mothers, sisters and daughters on the front lines, I’ve been torn on this topic. Many on the right wonder if we’ve been wrong for 200 years, or if sending women into battle will improve America’s military.

    What follows is a slightly modified transcript of our thread on Facebook.

    Me: I want to know what you think about women on the front lines. It seems “fair” now, but what if they re-institute the draft? What then?

    LCC: First, it’s about freaking time. Jobs should be open based on skills and abilities, not reproductive organs.

    Second, I think women should have to register for the draft. And I also like the idea of compulsory service, although I would suggest making it “service” not “military service.” I don’t want people compelled to be in the military—that results in a less capable force, and I don’t want someone who is non-committed to be the only thing standing [sic] between me and the bad guy.

    Me: I would like to think I’d be brave enough to stand between you and the bad guy, but I know I’m not. Do you think women can handle combat?

    LCC: Most women won’t be able to do it. That’s a fair statement. As long as the ones who can are allowed to, all is well. And it’s not just about our “rights” — it’s also about ensuring you have the best people where you need them.

    Me: How do you think women should be measured up to their male counterparts, physically? How would you handle that?

    LCC: My answer to the inevitable questions on physical standards is this: It’s perfectly appropriate to have different measures of overall fitness for men and women. If you take a man in great shape, and a woman in great shape, on average, the man will be able to do more push ups and run faster due to physiology. Abdominal strength doesn’t have the same kind of difference between the sexes. In effect, requiring everyone to hit the same numbers would require a woman to be in better shape than her male peer.

    That said, that’s only on tests designed to measure general fitness. If a job has certain physical requirements, then anyone doing that job should have to be able to meet them, and whether you’re male, female, or whatever is irrelevant.

    Those requirements should be reasonable and demonstrably tied to the job—in other words, fair game to say that you have to be able to drag a 200lb dummy at least 100 yards (or whatever you would typically be expected to do in battle). Not fair game to say “this job is physical…you have to be able to do 300 push ups.” Some fire departments tried to do that to keep women out when they were told they had to let them in if they could meet the standards. It would be equally unfair to design tests that deliberately take advantage of typically female attributes (I can see where there could be jobs where being smaller would be an advantage, but not necessary to do the job. It would be unfair to create a test that focuses on that—you’d be making it tough for most men who would otherwise be considered fit for the job to pass).

    We have plenty of jobs with size restrictions because you have to be able to use equipment. Others say you have to meet certain hearing and vision standards. Those are all specifically tied to the requirements of the job. As long as they stick to that, we’ll be fine.

    Me: So, in every platoon, the smallest guys aren’t as physically strong as the largest guys, but they still made it there. Many women who aren’t currently allowed in might be bigger and stronger than some of the smaller guys already there, right?

    LCC: Exactly. In every unit, you have a mix of strengths and weaknesses. Not every man is at the top of the charts on every measure of physical strength. It’s a combination of skills, with some level of physical ability that truly is required, that makes each person a solid contributor. So even if a woman ends up being the person who can do fewest push ups, that doesn’t mean her overall role in the unit isn’t solid. And she might well be the best shot in the bunch. Or the best something else.

    And it’s also important to note that being “weakest” on any given attribute is not the same as being “weak.” Would anyone call the person who finishes last in an Olympic race “slow?”

    Me: Wow, I just learned a lot of things I didn’t know about women in the military. Everything you said makes perfect sense so far. But, what about the charge that women who get captured in combat will be raped? And what about women on long tours of duty with men from their own company? Do you think more shenanigans will go down in our barracks?

    LCC: As far as sexual assault goes (the other reason often cited for women in combat being a bad idea), everything I’ve ever read on the subject says that when respect for women goes up, sexual assault goes down. Seems to me that while we might have issues initially, when women are not classified as inherently inferior and have the opportunity to prove themselves in the same arenas, we’ll have a better shot at women being seen as true equals.

    Me: What about male soldiers making dumb decisions in combat situations to protect their female counterparts?

    LCC: I’ve heard [sic] the arguments about how men won’t be able to handle seeing women getting killed around them, or they’ll risk themselves to “save” women who are down. To the second point, yes, they probably will. Just like they do to save their male comrades in arms. In my experience, when you’re competent and pulling your own weight, you quickly become “one of the guys.” I’d expect in a battle situation, you’d see warfighters pulling each other off the battlefield when necessary — and you’d see both men and women on BOTH sides of that equation.

    Me: Haven’t women been in support roles very close to the front lines for awhile now anyway?

    LCC: I’d say that we’ve been in combat for quite awhile. The “front lines” are amorphous—I rarely left my base, and my barracks still got blown up with a whole bunch of us in it. We also have women “attached” to combat units — going out on patrols, into villages, etc. The ban simply allowed a final bastion of discrimination that has been illegal almost everywhere else for decades, and prevented women from getting proper “credit” for work they were already doing.

    Not that I have strong feelings about this stuff.

    ME: LOL. I asked you about your personal opinion about women in the military specifically because I knew you’d have strong opinions, and they’d be much more informed than my own. Can I quote you on my blog?

    LCC: I don’t have a blog, so you are welcome to it. But everything here is my opinion/thoughts alone, not necessarily the position of DoD or the Navy. That’s important, because when I’m in uniform, my job is often to be a spokesperson for one or the other. I am most definitely NOT spouting off in that capacity here!

    Well, folks, there you have an honest personal opinion who’s been close to our front lines for quite some time now. Like every issue in the public, political sphere, there’s much more to it than meets the eye, and I always try to ask someone who has her finger on the pulse of an issue before I make up my mind.

    Thank you for your opinions, your voice, and your service, LCC, you’re much braver than I, and a patriot, and I salute you.

    May God protect you, and future U.S. women, out there protecting our freedom on the front lines.