tag:blogger.com,1999:blog-90240092372226715172024-02-20T20:16:46.839-05:00Boring Guys Blogasp.net, c#, linux, php, mysql, git, and development info by Rich ZyglerUnknownnoreply@blogger.comBlogger109125tag:blogger.com,1999:blog-9024009237222671517.post-33639004289531404552014-03-21T10:01:00.002-04:002014-03-21T10:02:11.841-04:00Commit your local git branch changes first, then checkout another branchOne of the things people get confused about is the branching in Git, specifically, the local branching. If you make a local branch, make code changes and then commit those changes to the local branch, you are free to switch to another branch and Git will automagically manage your files for you. From the<a href="http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging"> git book</a>:<br />
<br />
<blockquote class="tr_bq">
Git resets your working directory to look like the snapshot of the commit that the branch you check out points to.</blockquote>
<br />
But it's very easy to make a mistake here. If you don't commit the changes in your new branch and instead check out another branch, those changes will be there too. I've seen this cause confusion with developers. So if you make a local branch off your "develop" line:<br />
<br />
<blockquote class="tr_bq">
git checkout -b NewBranch develop </blockquote>
<br />
and make some changes to files, you have to commit those changes to "NewBranch" or you'll still see them as modified files if you switch back to the "develop" or "master" branches. Now if you commit those changes to NewBranch line first, then checkout "develop," you won't see them as modified, and the files will instead be in their state from the "develop" branch.<br />
<br />
Happy Local Branching!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-89573875322127287092014-02-23T08:04:00.002-05:002014-02-23T08:08:47.564-05:00ASP.Net Razor Syntax for using a variable in html or html attributeBecause I always forget how to do this, here's a quick note on the Razor syntax in an html variable. For a integer variable named:<b> imgWidth</b> that has a value of 214 you can put it in an html attribute like this:<br />
<br />
<pre><b><div style="width: @(imgWidth)px;"></b>
</pre>
and it will render like this:<br />
<br />
<pre><b><div style="width: 214px;"></b></pre>
<br />
I know I know. The css gurus will be lambasting me that I put inline styles in this example. So sue me. Sometimes inline styles are necessary.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-88458616599102115952013-11-27T09:58:00.002-05:002013-12-01T07:24:05.672-05:00Whoever says Google has poor support is wrongI use a few of the Google tools available. When it comes time for my monthly backups of my web stuff, I use Google Takeout. <a href="http://www.google.com/takeout" rel="nofollow">Google Takeout creates a backup</a> of all your Google stuff and creates one big zip file of it that you can download to your machine. <br />
<br />
I had some trouble with it today, it wasn't generating my download file so I sent an email to their support team. I got an email back in about five minutes:<br />
<br />
<br />
<span style="background-color: white; color: #222222; font-size: 13px;"><span style="font-family: Courier New, Courier, monospace;">Hi Rich,</span></span><br />
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;">Thanks for your mail. We're currently working on this issue, we hope to have it resolved by next week. Sorry for the inconvenience,</span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;">--The Takeout team</span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif;">
So I'll try again next week and see if its working as expected. But overall not bad support for what is essentially a suite of free tools.<br />
<br />
UPDATE 11/30/2013:<br />
<br />
Another Googler got back to me and said to try again, and sure enough it worked just fine. Problem solved. Thanks Google. Now get back to keeping the NSA from spying on my appetizer recipes in Google Docs.<br />
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-89016215513801244762013-11-14T16:19:00.001-05:002013-11-14T16:19:23.384-05:00Visual Studio using old app.config value or settingOnce in a blue moon, I will run into a problem with Visual Studio 2012 where the App.config for a console application is getting cached somewhere and there's no way to release it. So the App.config is stuck with old values which aren't correct for the application today. It's happened maybe twice this year to me. <br />
<br />
The App.config in my solution shows the correct values. The one that's been put in the output directories for Debug and Release both look good, but my quick little console application is pulling ghost values from an App.config from last week. I've tried building, rebuilding, and finally, all to no avail.<br />
<br />
The only thing I could think of to fix this ( which did work ) was:<br />
<br />
<ul>
<li>Copying the contents of the App.config file from within Visual Studio</li>
<li>then delete the file from within Visual Studio</li>
<li>Then re-add the config file</li>
<li>Then paste in the contents.</li>
<li>Rebuild and run.</li>
</ul>
<div>
I'm going to chalk this one up to ghosts in the machine. </div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-13345223905189485062013-06-21T10:18:00.000-04:002013-06-21T10:18:23.479-04:00Amazon Kindle, Expired Credit Card and Gift Card Balance issueRan into a weird problem with the Amazon Kindle in our household. They don't let you purchase a new book when you have an expired credit card in your one-click setup, even if you have a gift card balance on the account. We couldn't figure it out on the Kindle, so I had to login to Amazon, delete the expired credit card, and then the purchase went through with no problem via the gift card. It's funny because with so many of these devices today, when you actually have to break out the computer and go to a website, it feels jarring and old-fashioned.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-76384166239010521462012-09-25T07:54:00.000-04:002012-09-25T07:54:00.095-04:00How to get the address of the svn server for my subversion repository?<br />
<div style="font-family: arial; font-size: small;">
Recently, I had some code from a Subversion repository on my machine, but no longer had tortoise svn or any svn command lines tool set up. Luckily, I remembered that in Subversion there is a lot of fun data inside the .svn directory. For instance you can see the address of the server and repository by viewing the .svn/entries file at the root of the local subversion files. Just look for the svn:// or svn+ssh:// </div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
That line should show you the svn server address, as well as the repo name and branch.</div>
<div>
<br /></div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-38017206360539241012012-09-18T08:00:00.000-04:002012-09-18T08:00:00.175-04:00ASP.NET MVC Model binding in PHP?I've been working a lot this year with ASP.NET MVC 3 and C#. One of the things I really like about these technologies is the model binding. Let's say I have a data model called "User", a plain old C# class like this:<br />
<br />
<br />
<script src="https://gist.github.com/3739330.js?file=poco_user_model"></script>
<br />
I can set that as a model for my view to use in the "Edit" controller like so:<br />
<br />
<br />
<script src="https://gist.github.com/3739344.js?file=aspnet_mvc_edit_controller"></script><br />
<br />
And then I have "User" as the data model in my view. Here's what's awesome about it, let's say I need to accept edits of the user account, maybe they can fix their first or last name. I can pass that same User model from the previous page via a form into an Edit method that accepts that data model. I don't have to muck about with assigning the Request variables ( POST / GET ) to an object. All that is handled for me.<br />
<br />
<script src="https://gist.github.com/3739351.js?file=aspnet_mvc_httppost_edit_controller"></script><br />
<br />
The ASP.NET MVC model binding will attempt to bind your model in these scenarios:<br />
<br />
- If you have a form element on the page with an idenitical name to a property in the model<br />
- If the url contains a key value pair from your routing that is identical to a property in the model<br />
- If any REQUEST element has a name that is identical to a property in the model<br />
- Otherwise, that property of the model will remain null<br />
<br />
Plus, the ASP.NET MVC model binding will let you turn on/off model binding for various properties of the model.<br />
<br />
PHP, or rightly, the many PHP frameworks really need to implement something like this. A few perform some pieces of this concept but I'm not aware of any that currently serve up the whole enchilada. What do you think?<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-86584327692460248322012-09-17T12:40:00.000-04:002012-09-17T12:40:51.635-04:00Database stored procedures, functions and triggers are source code of your application. Please treat them as such.<br />
<div style="font-family: arial; font-size: small;">
As a consultant for the past two years, when I come into a batch of code that has many stored procedures or triggers in the database, the first thing I ask is whether those stored procedures and triggers are under some kind of revision or source code control. If the developers/DBAs look at me like I've got two heads, then I know I'm in for a doozy of a gig because those devs are probably not doing the best job they could be doing.</div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
And that makes sense right? You don't call in a consultant if everything is unicorns and rainbows with your system.</div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
Stored procedures, functions, and triggers in your database are part of your codebase. They could even be the most important and most delicate piece of your codebase.</div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
I'll repeat this again for total clarity... Stored procedures, functions, and triggers in your database are part of your codebase.</div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
But not managing your codebase with a tool is a huge mistake. And yet, I see this time and time again on my gigs. And if I had a nickel for every time I saw a stored proc named with "_new" or "_new2" or "_use_this_one" in the name, I could invite Warren Buffet over to play cards and he would consider it.</div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
For managing the source code of your stored procedures on SQL server, there's even some commerical tools available that take your database objects and chucks them into your source code repo. Or you can always just create a "sql" directory in your source code repository and store the objects there. </div>
<div style="font-family: arial; font-size: small;">
<br /></div>
<div style="font-family: arial; font-size: small;">
There are a lot of ways to manage this problem. Ignoring it, is not managing the problem, it's making it worse.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-74738696730351344112012-02-11T11:56:00.000-05:002012-02-11T11:56:03.338-05:00Turned off my "home page" today<br />
<div class="p1">
I turned off my web hosting today that hosted my home page and a few small facebook apps that weren't making any serious money. It's kind of the end of an era for me. I've hosted my own web page and small apps since probably 1997. </div>
<div class="p2">
<br /></div>
<div class="p1">
These days it just doesn't make much sense to host your own anything. The cloud is our new overlord and I for one love the stuffing out of it.</div>
<div class="p2">
<br /></div>
<div class="p1">
You can have code at github and bitbucket for free (bitbucket does private repos at no cost - yay! ).</div>
<div class="p2">
<br /></div>
<div class="p1">
You can have your blog on blogger or wordpress.</div>
<div class="p2">
<br /></div>
<div class="p1">
You have your random one-liners and cries for help on twitter.</div>
<div class="p2">
<br /></div>
<div class="p1">
You have linkedin so that recruiters can spam the daylights out of you with terrible positions in far away countries.</div>
<div class="p2">
<br /></div>
<div class="p1">
You have roughly a ba-jillion services for hosting your small apps, like Heroku, PHP Cloud, Google App Engine, and Azure.</div>
<div class="p2">
<br /></div>
<div class="p1">
I just can't justify the expense of a basic web hosting or virtual server account any more. I won't miss doing the system administration on that thing and constantly worrying about hackers. That's for sure.</div>
<div class="p1">
<br /></div>
<div class="p1">
I still need a proper home page for my domains to link to all my various cloud identities. Any suggestions?</div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-9024009237222671517.post-64325886334596916432011-10-15T09:44:00.000-04:002011-10-15T09:44:52.096-04:00Review of Siri voice app for iphone 4sI've been playing with Siri on the new iphone 4s for about 12 hours now and I can honestly say I'm quite impressed with the features. The small help section within Siri gets you going quickly with example commands. When Siri doesn't understand a command, she prompts you to do a web search for that phrase. Of course saying things like "google barack obama" or "search for barack obama" also command her to do a google search for those terms.<br />
<br />
A lot of the examples show how you can text, email, or call using Siri by just referring to a person's first name. <br />
<br />
"Text Vinny"<br />
<br />
"Email Vinny"<br />
<br />
<br />
If you have multiple Vinnies in your contacts, Siri will show you a list and prompt you to choose one. This makes perfect sense. However, the voice commands don't appear to work very well for choosing which Vinny. Siri doesn't seem to understand names very well ( which from a programmers point of view makes perfect sense ). I was hoping that it would work like most phone systems work however, where I could say "one" and Siri would select the first Vinny in the list or "two" for selecting the second Vinny and so on. It doesn't work like that. So you either have to click the "Vinny" that you want or try to say their whole name in the original request like: "Email Vinny Boombotz." And you have to really pronounce names phonetically ( not necessarily how they're pronounced ) to get the right name to show up.<br />
<div>
<br /></div>
<div>
The same issue comes up with email addresses. When you command:</div>
<div>
<br /></div>
<div>
"Email Vinny Boombotz"</div>
<div>
<br /></div>
<div>
If Vinny Boombotz has multiple email addresses, Siri will show you a list of Vinny's email addresses and prompt you to choose one.</div>
<div>
<br /></div>
<br />
I've found that text commands work better than email commands and that's usually because most of my contacts only have one mobile phone number and therefore one texting address. Saying "Text Vinny Boombotz" will have Siri prompt you for the body of the message. Saying "Text Vinny Boombotz I'll be right over" will have Siri put "I'll be right over" in the body of the message. Pretty handy.<br />
<br />
Creating meetings and reminders works very well. When you say "Remind me to call Vinny Boombotz at 8:30pm" Siri will set up a reminder for 8:30pm with Vinny's number attached. So the reminder winds up with a "call" button on it for easy dialing.<br />
<br />
Commands like "what's the weather today" and "show me today's meetings" are pretty handy as well. <br />
<br />
Commands like "Find me an italian restaurant" have Siri locate italian restaurants local to you. Clicking on one shows a map and then clicking on the map label will show you the phone number and address of the restaurant.<br />
<br />
There's a whole slew of mapping functions that I haven't even tried yet.<br />
<br />
The Wolfram Alpha piece of Siri is kind of like the ultimate bar bet tool. You can ask questions like:<br />
<br />
"Who won best actor in 1982?"<br />
<br />
"Who won the SuperBowl in 1986?"<br />
<br />
"What's the population of China?"<br />
<br />
"How many calories in an Egg McMuffin?"<br />
<br />
And the Wolfram Alpha piece kicks in and gives you a handful of information on your topic. Again, if its not in Wolfram Alpha, then it falls back to a web search. But I found this much quicker then typing in a search. I'm probably going to use this piece of it quite a lot.<br />
<br />
There's also a <a href="http://blog.boringguys.com/2011/10/fun-questions-to-ask-siri-for-iphone-4s.html">bunch of fun questions you can ask Siri</a> that I mentioned here.<br />
<br />
There's big things missing from Siri right now that I hope get improved. There's really no concept of "latest news" or "latest baseball scores." Siri will prompt you to do web search for these terms. Ideally, they should open up the API to/from Siri so that if you ask for "latest baseball scores" it can query ESPN or another sports outlet for that request. It would be really killer if when you created iphone apps that you could register some Siri answers in your app so certain questions would go to your app instead of just a default web search from Siri.<br />
<br />
So in the baseball case, the ESPN app could register answers with Siri to questions like "Latest baseball scores" or "Next Texas Rangers game." So if Siri couldn't find the answers to those questions, it could question the ESPN app on your phone for those questions, before doing a default web search.<br />
<br />
In conclusion, I think Siri is a nice addition to the iphone. It's not quite a killer app but its definitely useful and something I'll probably be using a few times a week.<br />
<br />
<br />
<br />
<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-88691964803294249402011-10-15T08:30:00.000-04:002011-10-16T05:26:33.655-04:00Fun questions to ask Siri for iphone 4s<div>
In addition to the usual helpful things like sending texts and setting up appointments, Siri also responds to a bunch of silly questions as well. Try these and see what you get:</div>
<div>
<br /></div>
What is the meaning of life?<br />
<div>
<br /></div>
<div>
Siri, what is your favorite color?</div>
<div>
<br /></div>
<div>
Siri, how old are you?</div>
<div>
<br /></div>
<div>
Siri, how do you work?</div>
<div>
<br /></div>
<div>
Knock knock?</div>
<div>
<br /></div>
<div>
<br /></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-9024009237222671517.post-71060962212378319122011-08-25T12:02:00.000-04:002011-08-25T12:02:59.219-04:00On Technical Recruiter Spam <br />
<div class="p1">I haven't updated my linkedin or dice.com profiles in about a year. I figured by not updating those profiles that it would slow down the constant onslaught of recruiters phoning and emailing me about web developer positions. It hasn't worked so far. I really appreciate someone giving me the opportunity to apply to interesting jobs but the recruiting industry is just broken and full of lazy people who can't be bothered to do anything other than a simple keyword search. I have a lot of experience so I'm going to show up in a lot of keyword searches but that doesn't mean those jobs are applicable to me or that I would be interested in them.</div><div class="p2"><br />
</div><div class="p1">So if you're going to contact me anyway, you might as well try not to annoy me. Here are some ways dear recruiter of not annoying me:</div><div class="p2"><br />
</div><div class="p1">1.) If my profile lists that I'm not willing to relocate then don't send me a job clear across the state. Or the country. Or the world. These would require relocation. While I realize that New Jersey is one of the smaller states in the union, it is still 166 miles north to south and 57 miles wide. Since I live towards one end of it as referenced by my address, it makes little sense to assume I can commute to the other end. That's over a 100 mile commute. A quick google map search could give you that. </div><div class="p2"><br />
</div><div class="p1">2.) If the job entails working WITH a "guru," "ninja," or "rock star" then I am not interested. A real guru is much too enlightened to ever refer to themselves as a guru, nor would they allow another to refer to them as such. So when I see "guru" as my potential boss/coworker, I read "asshole." A ninja would have altered the job ad before it went live so as to preserve his identity. And rock stars aren't developers. They are girls named Kim that play bass guitar.</div><div class="p2"><br />
</div><div class="p1">3.) If the position entails that I NEED to be a "guru," "ninja," or "rock star" then I am not interested. Please see above.</div><div class="p2"><br />
</div><div class="p1">4.) If my profile lists I'm looking for full time work, then don't send me jobs that aren't full time. I really don't get this one. And I don't have anything funny to add to it either. It's really just sad that people don't pay attention to this.</div><div class="p2"><br />
</div><div class="p1">5.) If the position requires being an expert in some technology that I don't have as my primary skill set, then don't bother contacting me because I probably couldn't even do the job. </div><div class="p2"><br />
</div><div class="p1">6.) Stop asking for "excellent communication skills." If I had those, I wouldn't be a developer, I would be a salesman. Or Steve Jobs. I can communicate well enough to get the point across the first time. Is that excellence? Perhaps to you it is, but you also think the world is full of gurus and ninjas so I can't really take your assessment at face value.</div><div class="p2"><br />
</div><div class="p1">7.) If the position does not require me to write code to get a job offer then I'm not interested. Because that means your other developers didn't need to write code to get their jobs there and probably two-thirds of those developers are terrible. I don't want to work with terrible people. The better job you do at weeding out the crappy developers, the more I will think of your organization.</div><div class="p2"><br />
</div><div class="p1">8.) If the position is for a company whose name you cannot divulge until we've had several conversations then I'm not interested. I understand not putting the name in the job ad online, that's pretty standard these days, but if you're contacting me directly then you should give me the name of the company. Otherwise it implies a lack of trust on my part, like I'm going to steal this commission from you somehow. So, first, you're making contact with a stale account since I haven't updated my profile in a year. So you're assuming I'm looking for job when I'm probably not. And then to try and entice me into the job market, you neglect to give me the company name so I can do research on it? That's pretty lame.</div><div class="p2"><br />
</div><div class="p1">I could go on and on here, but what about you? What are your suggestions for technical recruiters?</div><div class="p1"><br />
</div><div class="p1"><br />
</div>Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-9024009237222671517.post-26091061534759778562011-08-07T08:10:00.000-04:002011-08-07T08:10:01.418-04:00How to find all the distinct PHP session variables that your applications uses.<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: arial, sans-serif; font-size: 13px;">The short answer is a one line *nix shell command:</span><span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 13px;"></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -hor "\$_SESSION\['[A-Za-z0-9_]*'\]<wbr></wbr>" * | sort -u</b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">This command: </div><div style="font-family: arial, sans-serif;"></div><ul><li>looks through all the files in your application recursively for the PHP $_SESSION reference</li>
<li>finds any variables named with capital letters, or lowercase letters, or underscores, or numbers</li>
<li>sorts the list alphabetically </li>
<li>removes the duplicate items in the list</li>
</ul><br />
<div style="font-family: arial, sans-serif;">The long answer is that I found myself with an interesting dilemma recently. How to find all the PHP session variables set in my application. Some pieces of the application were new code, some were older legacy code. I needed to get the full list of session variables because I needed to delete most, but not all of them for a certain usage case ( ie, the user is still logged in and has some properties, but the other session data could be safely destroyed ).</div><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 13px;"><span class="Apple-style-span" style="font-family: arial, sans-serif;">So I began with some command line greps on linux. First I tried:</span><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -r \$_SESSION *</b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">This was a decent list, but about 1000 rows long. Too unwieldy to deal with. Let's get rid of the filenames, I don't really care where the session values are set for my case.</div><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -hr \$_SESSION *</b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">This is a little better, but I don't need the whole line, just the session variable itself. Let's see if we can start to grab the session var using a regex pattern.</div><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -hor "\$_SESSION\[" *</b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">That's getting us closer. Now, I know ( or assume ) that my variables will only include upper/lower case letters as well as numbers and underscore. Let's add those to the pattern. ( you DO speak regex don't you? )</div><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -hor "\$_SESSION\['[A-Za-z0-9_]*'\]<wbr></wbr>" * </b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">Now we are cooking. This is a nice list of the session variables ( albeit only one array level deep which is all I needed ). Now how to remove the duplicates? Maybe we should "sort" them first?</div><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -hor "\$_SESSION\['[A-Za-z0-9_]*'\]<wbr></wbr>" * | sort </b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">That is really close. Is there a way to remove duplicates with the "sort" command? Yes, there is. Hot dog.</div><div style="font-family: arial, sans-serif;"><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>grep -hor "\$_SESSION\['[A-Za-z0-9_]*'\]<wbr></wbr>" * | sort -u</b></span><br />
<div style="font-family: arial, sans-serif;"><br />
</div><div style="font-family: arial, sans-serif;">There it is. That's the final command I used which located around 50 variables in the old legacy code and new modular code that were used in the sessions. The only really drawback to this code is it will not find multiple nested array values on the session itself, but you could add that as a separate regex if you need.</div><div style="font-family: arial, sans-serif;"><br />
</div></span>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-9024009237222671517.post-84756534117225110972011-07-25T12:57:00.003-04:002011-07-25T12:59:42.793-04:00Yahoo email account hacked<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
</style> <br />
<div class="p1">My wife started sending me emails about male enhancements around 3am Saturday morning. I first took slight offense to this but quickly realized they were addressed to everyone in her address book. Her Yahoo email account had been hacked.</div><div class="p2"><br />
</div><div class="p1">We updated her account password, alerted Yahoo security via a basic form on the Yahoo site, and added a "sign-in seal" to the account.</div><div class="p2"><br />
</div><div class="p1">But really, this should not have happened in the first place. There's a page in the Yahoo accounts menus that shows you the last 20 or so places you've logged in from. There's a bunch from our hometown and then a couple in France. She's never logged into Yahoo from France. Ever. Shouldn't Yahoo be throwing a red flag on that and displaying some of the maiden name, first pet name questions?</div><div class="p2"><br />
</div><div class="p1">The other disappointing piece of this is that there's no "sign me out of everywhere" button, you can only opt to be signed out every day.</div><div class="p2"><br />
</div><div class="p1">This is really terrible security. I haven't forced her to switch to Gmail yet but I probably will strongly urge her to do so in the coming weeks.</div><div class="p2"><br />
</div><div class="p1"></div><ul><li>Gmail has two factor authentication which practically eliminates this.</li>
<li>Gmail has a button to sign you out everywhere</li>
<li>I *think* Gmail has something if you're logging in from a different country ( but I'm not positive on that )</li>
</ul><br />
<div class="p2"><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-70216734499385841642011-07-12T08:49:00.000-04:002011-07-12T08:49:46.004-04:00Diary of a mysql database problem in 15 minutes<div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:42pm</b> - frantic instant message comes in from a smallish project that their site is down.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:42pm</b> - I ssh into both the webserver and the database server. Database server takes awhile to actually get a login prompt.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:43pm</b> - Email containing frantic instant message with importance set to high ( side note- people still use importance in emails? people still email after they've contacted you another way? people still email? )</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:44pm</b> - I run "top" on both the webserver and the database server. ( There isn't any other monitoring since it's a smallish project. there probably should be. Will have to get client to pay for that.) Webserver looks fine. Database server load is really high, around 5 when it's usually around 0.30. This is a mysql linux server.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:45pm</b> - exit "top" and open a mysql command line prompt.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:46pm</b> - execute "show processlist" in mysql. A ton of queries show up, all behind one sinister looking one on a new table that's been set up recently.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:47pm</b> - execute "explain sinister-looking query" in mysql to see how mysql is executing that query.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:48pm</b> - possible_keys = NULL</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:49pm</b> - Ruh roh. Execute "alter table add index..."</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:50pm</b> - database working.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:51pm</b> - database working.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:52pm</b> - database working.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:53pm</b> - database done working. execute "show processlist" to see 2 queries left on stack.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:54pm</b> - Execute "top" command, load is down to 2.7 and falling. 1.9 now. 0.70 now.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:55pm</b> - Declare crisis averted via instant message and email. Wonder again if people still use email.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:56pm</b> - Assign developer responsible for non-indexed table the task of making sure the schema changes get into source code control.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><b>1:57pm</b> - Go back to regular work.</div><div style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"><br />
</div>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-9024009237222671517.post-19427351243909412282011-07-11T12:21:00.000-04:002011-07-11T12:21:55.906-04:00Write helpful code comments or none at all.Stumbled onto the following comment in some code I'm working on:<br />
<br />
<b>//Code updated by Crappy Developer - 06/22/2011. Fix for Prod problem.</b><br />
<br />
This is a terrible code comment. I would rather you not even put this comment into the code.<br />
<br />
First off, I've replaced the name of the developer with "Crappy Developer" to protect their public persona and since that's how they are now known to me.<br />
<br />
The comment "Fix for Prod problem" tells me nothing. Aren't all problems Production problems? Otherwise, they're not problems. What was the actual bug? Under which circumstances was it reproducible? How did you fix it? Any tricky business logic involved here?<br />
<br />
And then there's the "//Code updated by.." You might think that giving the date of the fix and the developer's name is at least a little bit helpful, but all of that can be discovered with "git blame." This clown probably doesn't know "git blame" exists. I'll have to send him the man page on that.<br />
<br />
So the next time you leave a comment in the code, make sure its worth the time of the next developer that might see it. And make sure they aren't just going to blog about how terrible your comment was. You're wasting time with lame code comments, so please stop it.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-66034635323404835442011-07-08T05:41:00.000-04:002011-07-08T05:41:07.385-04:00Using Gmail "Details" link to discover older IP addresses<span class="Apple-style-span" style="border-collapse: collapse; color: #333333; font-family: arial, sans-serif; font-size: 13px;"></span><br />
<div>For one project that I'm working on, they have a very strict firewall setup which restricts SSH access to only internal machines and those temporary machines outside the network that need access ( like if you're working from home ). So as my IP address changes at home, I need to notify the service that my IP address has changed from A to B. The service prefers if I can give them both the old address and the new address because they'll take out the old address from the firewall rules and add access for the new IP address ( yes, they are that anal ). I was keeping this list on a pad by my desk but today I found myself downstairs, away from that pad, so I couldn't find my previous IP address, just the new one.</div><div><br />
</div><div>Fearing that I would have to walk ALL the way upstairs to get that pad, I thought for a few seconds and remembered the "Details" link in the footer of my gmail page. Clicking "Details" in the footer of gmail will show you the last 10 instances of logins/refreshes to your gmail page. Sure enough, I was able to find the number 7 entry was from last night and showed my previous IP address. I copied it into my firewall request and got back to my work.</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-13874769904518217862011-03-03T16:32:00.001-05:002011-03-03T16:34:10.851-05:00MySql tip for displaying query results verticallyI have a need at the day job to view mysql records via the mysql command line client. Some of the tables I'm looking at have 100 to 200 columns so it's pretty annoying to view this data horizontally across the screen. If you end your queries in the mysql command line client with \G instead of a semicolon, then it will display the results vertically down the page. Try it out!<br />
<br />
SELECT * FROM users WHERE id = 72 \GUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-19228867728507883442010-12-15T17:30:00.000-05:002010-12-15T17:30:28.377-05:00How to drop multiple tables in mysql at onceThere are a couple of different ways to remove multiple tables from MySQL at one time. Almost all of the ways of dropping many mysql tables at once are dangerous and that's probably why the MySQL developers have overlooked this "feature." You run the risk of dropping tables outside of the ones you meant to drop.<br />
<br />
But if you're dead set on this, here's <a href="https://github.com/rzygler/misc/tree/master/mysql/proc_drop_tables">a stored procedure for dropping multiple MySQL tables at one time</a> that does the job quick and easy.<br />
<br />
First you have to add the procedure to the schema. You can technically add this to any schema that you have access to. The way I use it is from a "global" schema that needs to make changes to other schemas that all have similar names. The MySQL user calling the procedure needs to be able to perform the DROP as well as READ the information schema tables. Don't mess with your permissions unless you have to however.<br />
<br />
<pre style="white-space: pre-wrap; word-wrap: break-word;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;"><b style="background-color: #f3f3f3;">-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE PROCEDURE `drop_tables`( db varchar( 100 ), pattern varchar(100))
BEGIN
SELECT @str_sql:=concat('drop table ', group_concat( concat(db, '.', table_name)) )
FROM information_schema.tables
WHERE table_schema = db AND table_name LIKE pattern;
PREPARE stmt FROM @str_sql;
EXECUTE stmt;
END</b></span></pre><pre style="white-space: pre-wrap; word-wrap: break-word;"></pre><pre style="white-space: pre-wrap; word-wrap: break-word;"></pre><br />
Once the procedure is set up, to test it out,<a href="https://github.com/rzygler/misc/blob/master/mysql/proc_drop_tables/test_tables.sql"> you can use the test_tables.sql file which adds a bunch of tables to your schema</a>. <br />
<br />
Calling the procedure can be done with:<br />
<br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">call drop_tables( 'test', 'jjj%' );</span></b><br />
<br />
So in this case, I'm dropping all the tables that start with "jjj" in the "test" schema. The "pattern" parameter can be any valid MySQL "LIKE" parameter.<br />
<br />
In a MySQL client, it looks like this:<br />
<br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">mysql> call drop_tables( 'test', 'jjj%' );</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">+------------------------------------------------------------------------------+</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">| @str_sql:=concat('drop table ', group_concat( concat(db, '.', table_name)) ) |</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">+------------------------------------------------------------------------------+</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">| drop table test.jjj_test1,test.jjj_test2,test.jjj_test3,test.jjj_test4 |</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">+------------------------------------------------------------------------------+</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">1 row in set (0.00 sec)</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;"><br />
</span></b><br />
<b><span class="Apple-style-span" style="background-color: #f3f3f3; font-family: 'Courier New', Courier, monospace; font-size: x-small;">Query OK, 0 rows affected (0.21 sec)</span></b><br />
<br />
<br />
Now, obviously, if you put in a pattern that returns no resulting table names, then you'll get an error. But fixing that error is left to the reader as an exercise ( do feel free to contribute that back to me!)<br />
<br />
Any questions or comments? Do you have a better way to do this?Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-28056129862781951882010-12-13T16:06:00.002-05:002010-12-20T05:09:44.929-05:00Explode a string with no delimiter in PHPI needed a way to split a string by the character and put the results in an array. Sounds like the perfect job for the explode function right? Well, according to the manual:<br />
<br />
<span class="Apple-style-span" style="background-color: #f1c232; border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;">If <i><tt class="parameter" style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-style: italic;">delimiter</tt></i> is an empty <span class="type"><a class="type string" href="http://us2.php.net/manual/en/language.types.string.php" style="border-bottom-color: rgb(0, 0, 153); border-bottom-style: solid; border-bottom-width: 1px; color: #000099; text-decoration: none;">string</a></span> (""), <span class="function"><b>explode()</b></span> will return <b><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;">FALSE</tt></b></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><b><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;"><br />
</tt></b></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;">That's a bummer. </tt></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;"><br />
</tt></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;">UPDATE: I also tried </tt></span><span class="Apple-style-span" style="color: #222222; line-height: 16px;"><span class="Apple-style-span" style="font-family: inherit;"><b>str_split('whatever')</b> but that has some problems with foreign strings.</span></span><br />
<span class="Apple-style-span" style="color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 12px; line-height: 16px;"><br />
</span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;">But we can do something like this:</tt></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px;"><tt style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;"><br />
</tt></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: monospace;"><b>$str = "Let's split this string!";</b></span><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: 'Courier New', Courier, monospace;"><tt><b>// get the string length so we aren't paying for this in the loop </b></tt></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>$strLen = strlen( $str );</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b> </b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>// basically an "explode" on the string without needing delimiters</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>for ( $i = 0; $i < $strLen; $i++ )</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>{</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b> $arr[] = $str{$i};</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>}</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b><br />
</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>print_r( $arr );</b></span><br />
<br />
Enjoy! Let me know what other ways you can come up with to do something similar.Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-9024009237222671517.post-67285112883565829552010-11-06T08:14:00.000-04:002010-11-06T08:14:24.574-04:00SQLSTATE[HY000]: General error: could not call class constructor<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>SQLSTATE[HY000]: <span class="il">General</span> <span class="il">error</span>: <span class="il">could</span> <span class="il">not</span> <span class="il">call</span> <span class="il">class</span> <span class="il">constructor</span></b></span><br />
<br />
This rather vague <span class="il">error</span> message has been popping up in some of my unit tests lately. It's a PHP error in PDO querying MySQL that happens when you're using the setFetchMode method of the PDOStatement. If you use the fetchMode of "FETCH_CLASS" you can get this error in one of three ways:<br />
<br />
<ul><li>The class you specified has not been included/required so when PDO gets results, it cannot create an object of the class you specified since it doesn't have that class definition.</li>
<li>Properties on the class you specified have been marked as protected or private and there aren't any setters for them so PDO can't set the properties on the new object.</li>
<li>You used the optional third argument "ctorargs" to give constructor arguments on your new object however your arguments are incorrect and don't match those on the class.</li>
</ul><div>Hope this helps other poor souls out there trying to figure this error out.</div><div><br />
</div><div><br />
</div>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-77362193463718643782010-11-05T12:47:00.000-04:002010-11-05T12:47:05.267-04:00"show tables not like" in mysql<div>I was looking for the tables in my database not starting with "p_". MySQL doesn't let you execute this command:</div><div><br />
</div><div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>show tables not like "p_%";</b></span></div><div><br />
</div><div>Which is odd considering it will allow "like" here:</div><div><br />
</div><div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>show tables like "p_%";</b></span></div><div><br />
</div><div>Instead, you have to use the information schema like this:</div><div><br />
</div><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>SELECT table_name FROM information_schema.tables WHERE table_schema = 'mydb' AND table_name NOT LIKE 'p_%'; </b></span><br />
<div><br />
</div>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-9024009237222671517.post-72192853411160048312010-10-30T21:39:00.000-04:002010-10-30T21:39:14.001-04:00Eclipse update conflict "Do you want to overwrite the changes made on the file system"Earlier today I kept running into a problem using Eclipse (really Zend Studio built on Eclipse) with a project running on the network that I accessed via a mapped drive on my Linux machine. The problem occurred during file saving and looked like this:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b><br />
</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>Eclipse update conflict "do you want to overwrite the changes made on the file system?"</b></span><br />
<br />
The only way I was really able to fix this problem was to make sure that both my machine and the networked machine in question had the same exact time. So I busted out ntpdate and made sure both machines were updating their time at least once a day using a command something like this:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>sudo ntpdate pool.ntp.org</b></span>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-66629186790288664182010-02-27T11:10:00.000-05:002010-02-27T11:10:02.248-05:00Export from Wordpress blog and Import to BloggerThis script exports your posts and categories from your locally hosted Wordpress blog and imports them into a new Blogger blog online. The script is based on the Blogger examples for working with PHP and blog data.<br />
<br />
<a href="http://github.com/rzygler/misc/blob/master/xfer_to_blogger.php">Code to export from hosted Wordpress blog and import to Blogger at github</a><br />
<br />
You need to have the Zend Framework up and running on your system as it contains all the GData libraries for working with Google data in PHP. This script doesn't use any of the MVC, so you just need to have the files somewhere that you can require them. <a href="http://framework.zend.com/">More on Zend Framework here.</a><br />
<br />
You need to edit line 8 to point to the path of your Zend Framework. You also need to update the database connection variables right below that to match your wordpress blog.<br />
<br />
Some caveats:<br />
<br />
<ul><li>Blogger can only import 50 blog posts per day before tripping some anti-spam protection. So the SQL "limit" clause around line 322 will need to be adjusted. It is set to get the first 50 posts and publish them.</li>
<li>Wordpress "categories" become Blogger "labels"</li>
<li>Blogger forces any imported comments to the blog posts to originate from you, the author, of the blog. So I have omitted these from my script, figuring it would look crazy to be talking to myself. You could hack this script to add those back in. </li>
</ul><br />
What's great about Blogger is that you can create a new test blog and run this script, which allows you to select which Blogger blog you wish to update and go from there.<br />
<br />
The usage is:<br />
<br />
<b>php xfer_to_blogger.php --user=email@email.com --pass=password</b><br />
<br />
The email and password here are the ones you used in setting up your Blogger account.<br />
<br />
Let me know how you make out and if you have any suggestions for the code.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-9024009237222671517.post-38669462255901679342009-09-13T02:39:00.001-04:002010-01-18T10:18:37.726-05:00Thinking of moving this blog to blogger.com or wordpress.comHaven't decided yet, but here's a nice summary of the features involved in <a href="http://pulsed.blogspot.com/2007/07/blogger-wordpress-chart.html">blogger.com vs wordpress.com</a>. I wonder if tumblr or posterous are more relevant now? I've got a ton of this old stuff to port over. Looks like I won't be able to show comments made by their rightful authors for old posts no matter which site I use. Decisions decisions.Unknownnoreply@blogger.com0