Skip to main content
I'm streaming on Twitch right now. You should stop by. Let's go!

Tagged: regex

  • ASP.NET/C# image resizer for responsive layouts


    I will probably elaborate on this a bit further when I find some more time, but for now, this post is going to be mostly code. What I have here is a relatively simple way to generate images that are resized server-side based on the screen dimensions (note: not window dimensions) of the web browser requesting them. This way, you're not sending huge images to phones. Pair this with some CSS to scale your images to fit their containers, and you're cooking with gas!  …

  • Lower-case specific query string keys with IIS URL Rewrite


    We're going through some normalization of URLs at my day job, which has necessitated some interesting rewrite rules for lower-casing specific query string keys. Essentially, we need to turn site=CampusName into site=campusname. After quite a bit of tinkering with IIS URL Rewrite rules, I managed to pull it off.  …

  • Validating file uploads in Sitecore WFFM


    Our Sitecore installation was in dire need of a way to lock down file uploads on forms built with the Web Forms for Marketers (WFFM) module; out of the box, it doesn't do any checking at all, which can lead to some risky situations. I tacked on a simple whitelist attribute to the UploadFile control, and our security engineer can breathe easy.  …

  • Bulk rename Subversion files with PowerShell


    Scenario: We're upgrading our reporting software at work, and the way that it used to integrate with SVN (through a terrible SCC bridge) involved arbitrarily placing "app_" at the head of the file names. Of course, in the new version, they no longer do this, and so all of our SVN references are out of whack. While renaming all of them to remove the "app_" at the beginning isn't the entire solution, it's one step I had to follow that I believe will be of benefit to others.  …

  • rexCrawler and HelpfulHighlighter are now open source


    After having dipped my toe in the water of open source with some Arachni module changes and the development of a simple WordPress plugin, I've finally taken the plunge; two of my personal projects are now completely open source, and hosted on github. Much of the code is stale—and somewhat embarrassing—but I figured that it was high time I shrug off that self-defensive apprehension and use it as fuel to make me a better developer.  …

  • WordPress plugin minify Makefile


    While working on my first commercial WordPress plugin, the need for build automation finally struck me. The environments in which I do my most development are all driven by Linux, and so I wanted to use a tried, true, and ubiquitous build automation mechanism to fulfill my need. As such, I wound up going with a Makefile, to be parsed and executed by the GNU make application. The result is an incredibly convenient automated build that minifies my Javascript/CSS (thanks to reducisaurus), and creates a version-appropriate archive of my plugin.  …

  • Easy SSL redirection for select folders in nginx


    I have many various web applications installed on my server; some of them need to be wrapped in a secure connection, while it is less important (or meaningless) for others. For those applications whose security I am concerned about, I've developed an easy way to force nginx to serve the application over an SSL connection. The method involves creating empty foldername.ssl files in a specific location, and then comparing the base folder name of an HTTP request against these file names. If there is a match, the connection is redirected to an https:// URL.  …

  • Kill all shared memory segments in Linux


    See update below. I recently whipped up a shell script to kill all (IPC) shared memory segments in Linux for a client on oDesk.com. He wound up going with another contractor's offer, and so I figured I would post my script here for the benefit of all.  …

  • Create anchor links in Twitter status text with JavaScript


    Note: This also applies to any service using a Twitter-compatible API, such as StatusNet (see: identi.ca) with some minor configuration changes. As a side project, I have been working on a StatusNet (specifically, identi.ca) status feed widget for the WordPress PHP platform. I had spent a fair amount of my time trying to convert the various tokens (such as @mentions, #hashtags, and URLs—both with and without a protocol prefix) into clickable links when I realized that StatusNet, being the cool folks that they are, provide HTML-rendered versions of status posts through their API. However, my work hasn't been for naught! Twitter uses an incredibly similar API—or rather, StatusNet's API is similar to/based off of Twitter's API—but does not provide HTML-rendered versions of the status posts (to my knowledge). With this in mind, I've re-engineered the code to accept options for pointing the various token URLs to the particular service—whatever it may be.  …

  • bulkRename v1.1


    A while back (in 2008), I wrote a simple system utility with VB.NET which leverages the power of regular expressions to rename files in bulk according to a pattern. I've had to use it several times recently after placing it on a metaphorical shelf to gather dust, and it got me thinking: Maybe other people can benefit from this utility. That's what software is supposed to be all about, right?  …

  • Replacing MS Word's quotation marks in VB.NET


    When dealing with text pasted from Microsoft Word, the presence of "special" (read: non-ASCII) quotation marks and apostrophes can be quite troublesome. Here's a simple way to convert them to "standard" (read: ASCII) quotation marks and apostrophes… VB.NET Code: #!vbnet …

  • URL rewriting template engine


    My employer is currently in the process of standing-up a content management system (CMS). In the process of migrating links on our existing site to the new CMS site, there are going to be—at least, at first—a metric tonne of possible URL redirects necessary. Since the majority of these will fall into a handful of categories, I began creating IIRF (Ionic ISAPI Rewrite Filter) URL rewriting rules that would, for instance, move a particular list of "Offices" from /offices/officename to http://newserver/offices/officename. (Note: These directives should be compatible with Apache's mod_rewrite, and even lighttpd's url.rewrite, as well.)  …

  • WebFOCUS Impact Analysis report compactor


    Here's a little script I whipped up to combine several Impact Analysis reports generated by WebFOCUS Developer Studio. The script opens HTM-formatted IA reports, skims the data, and then concatenates it all in one CSV-formatted output block.  …

  • Consuming newlines with the Javascript regex engine


    In most server-side languages (with an available regex engine), programmers are given a wonderful set of pattern modifiers. One such modifier for PCRE (Perl-compatible regular expressions) is the "s" modifier, known in PHP as the constant PCRE_DOTALL. This modifier will cause the "dot" character–which will usually match any normal character–to include newlines. This is especially useful if you are dealing with text files and your pattern match may span multiple lines of those files.  …

View all tags