Posts Categorized: Programming

PHP Monolog Choking on Large Log Entries

I’m using Monolog to log XML coming into a SOAP service and some of the XML is really long. I’m using a LineLogParser and it’s calling preg_match to parse each line of the log. Well on the big XML files, preg_match was hitting a “backtrack” limit. What I had to do was crank up the… Read more »

SVN Resolving Conflicts

While I guess it’s showing its age, but subversion is still a pretty good source control tool. My problem with it is that I’m always confused about what to do when I get a conflict. This is probably because I only deal with this issue a few times a year. Here’s what I do when… Read more »

Easiest Way to Customize a Symfony Form

Before I get started, I realize that Symfony has this entire form theming apparatus and it’s great. But this is a simple technique that puts the control of the form in the hands of the person laying out the HTML rather than the developer. All I do is when I’m rendering my form, I wrap… Read more »

SVN Merge Changes From Branch into Trunk using Reintegration

If you’re like me, when using subversion, you have a trunk, and then you create branches for code fixes and enhancements. But if you’re like me, you already know how to do this and so reading this is a waste of your time. But if you’re REALLY like me, you don’t remember all of these… Read more »

PHP Get the First of Next Month

While having fun with dates, I needed to get the timestamp for the first of the next month, here’s how I did it with PHP. strtotime(date(‘m’, strtotime(‘+1 month’)) . ‘/01/’ . date(‘Y’, strtotime(‘+1 month’))); I then used that to create a PHP DateTime object like this. $date = new DateTime(); $date->setTimestamp(strtotime(date(‘m’, strtotime(‘+1 month’)) . ‘/01/’… Read more »

Run SVN Merge Again Using –ignore-ancestry

I had an issue where I accidentally did a svn merge, but what I merged into had changes I didn’t want committed to trunk – yet. But I ran a commit before I realized my error. It’s a good reason to start with a fresh checkout of the code to merge to before doing it…. Read more »

Create SVN Branch with Copy Command

I create SVN branches all the time. If I get a few tickets to work on, I create a SVN branch and work there. Once the changes are done and tested, I roll the changes into trunk. Here’s how to SVN branch. svn copy https://mysvnrepositoryserver.com/dept/IS/MyProjectNameGoesHere/trunk \ https://mysvnrepositoryserver.com/dept/IS/MyProjectNameGoesHere/branches/NomeOfBranch \ -m “Creating branch for some reason.”

Symfony ChoiceType Default to Checkbox Checked

I’m rendering a bunch of checkboxes using a Symfony form type of ChoiceType and I want some of them to be checked by default. It’s basically a list of transactions and the ones that fail will be checked so that the user can fix whatever caused the problem and run them failed ones again. It… Read more »

How to Truncate a File from Command Line on Mac or Linux

I often get data files with a ton of data, but I only need the first few lines. It’s usually because I’m building out some test data for code I’m writing. I don’t need to create 2,000 accounts to run my code. Here’s how I figured out how to truncate a file from the command-line… Read more »