11
Mar 11

pgrep – Using PowerShell to fill the Windows grep void. Of pain.

I use windows at work. I hate the windows command line. I REALLY miss grep. PowerShell has Select-String which kinda/almost/sorta does grep things. Here is how you would actually use it in a grepish way:

Get-ChildItem -recurse -include *.txt | Select-String -CaseSensitive "SomeString"

Recursively searches all text files in the current directory tree for SomeString with case sensitivity.

This sucks to type. So let’s alias it to a function.

function pgrep { param([string]$search, [string]$inc) Get-ChildItem -recurse -include $inc | Select-String -CaseSensitive $search }

Now we can:

pgrep SomeStringToSearch *.txt

Then to really make it magical, add the function alias to your PowerShell Profile and you can almost dull the pain of not having proper command line tools.

07
Mar 11

Debugging in Node.js

Is as easy as:

  1. npm install node-inspector
  2. node-inspector &
  3. chrome to http://localhost:8080/debug
28
Feb 11

nodechat.js – Using node.js, backbone.js, socket.io, and redis to make a real time chat app

UPDATE 5 – This tutorial refers to intermediate builds of nodechat, referenced by tags. These will not work quite right due to breaking changes in Socket.io 0.8.X. The latest commit in Github has been updated to be fully functional and I will continue to maintain it as long as there is interest. I do not plan to fix the intermediate tags, so please keep that in mind as you go.

UPDATE 4 – The hosted instance of nodechat is no longer. The last round of changes from socket.io and Google Chrome have broken it and I am not particularly interested in fixing it. IRC does the multi-user realtime chat job quite nicely!

UPDATE 3 – There is now a follow up tutorial dealing with user profiles and socket.io authentication: Nodechat.js continued – authentication, profiles, ponies, and a meaner socket.io.

UPDATE 2Joyent has kindly give me a permanent home for nodechat.js: http://nodechat.no.de/. I made some more FUN minor improvements. Continue being ware.

UPDATE – For the fun of it, here is the demo code hosted on a Joyent no.de smart machine: http://nodechat.no.de/ . Have fun. Beware.

Sorry folks. I know it has been awhile since I have posted anything. Even longer since I have posted something worth reading. Life, busy, etc. No excuses.

I’ll be better from now on, I promise. To start, here is something so cool it hurts my brain. I present nodechat.js!

nodechat.js is a simple, realtime chat app that leverages node.js, backbone.js, socket.IO, and redis. I wrote it as an exercise and I am sharing it because there are relatively few working examples using all these pieces together.

Continue reading →

12
Dec 10

VimRepressed

In my September post about my blogging workflow, I mentioned that I was using a modified version of Vimpress. I decided to post it on github so anyone who is interested can check it out or change it. Check it out here: VimRepressed

I don’t really have any specific plans to update it. Let me know if you have any suggestions for potential features!

26
Nov 10

Fake your Chrome user agent to look like an iOS device

Another quick one: fake your user agent in Chrome to look like the latest and greatest iOS iPhone:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 
    -user-agent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) 
    AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5"

This is for a mac, but the same idea works on a PC, just fire up Chrome from the command line with the –user-agent flag.

26
Nov 10

iPhone application icons for your site

I finally got around to creating an application icon for fzysqr.com. It is super easy:

  1. Create a 114px x 114px PNG (retina display compatible).
  2. Upload it to your website somewhere it can be accessed (http://fzysqr.com/images/apple-touch-icon.png in my example).
  3. Create a link in your site header:

    <link rel="apple-touch-icon" href="/images/apple-touch-icon.png"/>
    
  4. If you want to keep iOS from automatically glossifying your icon, use rel=”apple-touch-icon-precomposed” instead.

13
Nov 10

New look for fzysqr

If you are visiting today, you might notice that things look a bit different around here. I finally got around to rolling my own theme for WordPress. I wanted to get away from the noise and the clutter of pretty much every WordPress theme I have ever seen and get back to basic usability and readability.

It should be HTML5 compliant (according to the W3C Markup Validator so please let me know if you come across any issues in Chrome, Safari, or Firefox. If you come across any issues in Internet Explorer (any version), don’t. When IE cares about web standards, I’ll care about IE.

You may also notice that comments have been disabled. I am tired of fighting the battle against spam. I still welcome your questions, insights, or complaints. Please send them directly to me at comments@fzysqr.com.

03
Oct 10

Django HttpResponseRedirect returns 301 instead of 302

If you have some code that redirects like this…

def index(request):
    return HttpResponseRedirect('/widget/create')

And you want to test it with assertRedirects() like this…

def test_widget_redirect(self)
    response = self.client.get('/')
    self.assertRedirects(response, '/widget/create')

And you can’t figure out why your test fails like this…

AssertionError: Couldn't retrieve redirection page '/widget/create': response 
    code was 301 (expected 200)

Then you should read this.

In short, add a trailing slash to your url.

'/widget/create/'
21
Sep 10

Use Notational Velocity, MacVim, WriteRoom, and Vimpress for the ultimate WordPress Blogging Workflow

My most recent post about Switching To Markdown got me started on a quest to find better tooling for writing, editing, and posting to fzysqr.com. As a .NET developer by trade, I have grown accustomed to one of the best development environments ever created (Visual Studio). After switching my home computing environment to OSX a few years ago, I haven’t been able to settle into a comfortable set of tooling for coding and blogging on my Mac. This causes me to go off on wild tangents every time I sit down at my Macbook Pro to try to be productive:

Me: I'll work on a new post for my blog.

(starts tapping away at the keyboard for a few minutes.)

Me: Ugh, it is such a pain to post and format code on WordPress. I'll just
    see if there is a better way.

(4 hours later)

Me: I've got it! Using these 10 new plugins and some custom python scripts 
    I found online, I now have the ultimate setup!

(Next day)

Me: Ugh, these custom scripts suck. There has to be a better way...

(repeat forever)

I am somewhere around iteration 50 in this hellish loop and I think I may have found a workflow worth keeping.

Continue reading →

10
Sep 10

Switching to Markdown

I am thirteen posts into my blogging career and I just discovered Markdown! As someone who writes html all day long for work, I find it strangely relieving to put away the angle brackets once and awhile (without resorting to yet another bad WYSIWYG editor). So there are going to be a few changes:

  • I am now writing my posts in Markdown
  • Using TextMate and the blogging bundle
  • I had to ditch the code syntax highlighting. (I haven’t found one that works with Markdown and WordPress)

The first two items are awesome. The third not so much. I would love to hear from anyone that has figured out a way to have their cake and eat it too.

So, if you see any garbled code on my old posts, please let me know and I will clean them up.

Thanks for reading!