jonyamo

  • Archive
  • RSS

What If Drivers Were Hired Like Programmers?

  • 11 months ago
  • Permalink
  • Share
    Tweet

Test PHP Mail Without an SMTP Server

One major annoyance I have encountered when developing PHP (or any language for that matter) is testing email notifications. This is mainly due to the fact that in order to send email from your computer you need to either have an SMTP server running or have access to one that you can utilize for testing purposes.

In my case, I had no immediate access to an SMTP server (and didn’t feel like scouring the Internet looking for some sort of free solution) and installing one on my computer was complete overkill. So, I came up with a simple solution that works for PHP.

All I did was write a simple class called NoSmtp that reads the contents of the sent email and creates a file on your local machine which can then be opened in the mail client of your choice (for me that would be mutt). The class is designed for use with PHP’s mail function, which when called, sends the mail contents to the command specified by the sendmail_path directive in your php.ini file, which by default is sendmail -t -i. So, all you need to do is change that directive to point to the location of NoSmtp.php and, voila!, you now have pseudo email functionality.

You can pull the code from my Bitbucket repo, bitbucket.org/jonyamo/nosmtp. And be sure the read the comments in the code for various config options.

    • #php
    • #smtp
  • 1 year ago
  • 11
  • Permalink
  • Share
    Tweet

Your problem with Vim is that you don't grok vi

onethingwell:

This run-though of some vi and Vim essentials has been doing the rounds over the last couple of days—well worth reading if you’ve taken either editor for a spin and ended up confused or frustrated (which is usually what happens when anyone tries vi/m for the first time!).

The section on the insane flexibility of copy ‘n’ paste in the two editors is particularly good—the moment I came across that stuff in Vim’s :help was the moment I stopped using other text editors.

    • #vim
    • #editors
  • 1 year ago > onethingwell
  • 30
  • Permalink
  • Share
    Tweet

97 Things Every Programmer Should Know

Pearls of wisdom for programmers collected from leading practitioners.

    • #acumen
  • 1 year ago
  • 25
  • Permalink
  • Share
    Tweet

Custom MySQL Prompts and Pagers

I prefer to perform all MySQL related tasks from the command line, and because of that there are two customizations that I couldn’t live without:

1. Custom prompts

Not only do I perform all tasks from the command line but I also on occasion have multiple connections open to different servers. So, instead of looking a boring prompt like this

mysql>

I prefer something a bit more informative such as

username@hostname:database>

You can set that by editing you my.cnf file like so

#----------------------------------
# file: ~/.my.cnf
#----------------------------------
[mysql]
prompt='\u@\h:\d> '

More options are available at http://dev.mysql.com/doc/refman/5.0/en/mysql-commands.html#id549417.

2. Custom pager

I use less as my default pager when viewing files and whatever else on my Linux boxes. I’ve got it set with all my favorite options by setting these two environment variables in my .bashrc

export LESS="-AFiRsX"
export PAGER="less"

And, now I can use it inside of MySQL when running queries by simply passing --pager when invoking mysql. This not only allows me to page through the results but also run searches if need be.

http://dev.mysql.com/doc/refman/5.0/en/mysql-commands.html#id548363

    • #mysql
  • 1 year ago
  • 26
  • Permalink
  • Share
    Tweet
Code generation tools which pretend to abstract out something, like all abstractions, leak, and the only way to deal with the leaks competently is to learn about how the abstractions work and what they are abstracting. So the abstractions save us time working, but they don’t save us time learning.
The Law of Leaky Abstractions
    • #acumen
  • 1 year ago
  • 21
  • Permalink
  • Share
    Tweet

PHP Automatic Error Detection in Vim

Coming from Emacs I was looking for something to replace Flymake for on-the-fly syntax checking in Vim. And that’s when I discovered Syntastic.

Syntastic is a syntax checking plugin that runs buffers through external syntax checkers as they are saved and opened. If syntax errors are detected, the user is notified and is happy because they didn’t have to compile their code or execute their script to find them.

PHP is currently my main programming language, hence the title, however, Syntastic supports many others.

https://github.com/scrooloose/syntastic

    • #vim
    • #php
  • 1 year ago
  • 8
  • Permalink
  • Share
    Tweet

Context-sensitive Documentation in Vim

Pressing K while in normal mode in Vim will, by default, look up documentation using the man utility for the keyword underneath the cursor. This is excellent for quickly researching builtin Linux utilities as well as functions from the Standard C Library.

Pretty awesome. What makes it more awesome is the ability to extend it to use whatever utility or script you want. And what makes it super awesome is the ability to change that utility based on the context of the current buffer. That means you can use pman for PHP, ri for Ruby, and perldoc for Perl without ever leaving Vim.

Simply add the following lines to your vimrc:

autocmd FileType php setlocal keywordprg=pman
autocmd FileType perl setlocal keywordprg=perldoc\ -f
autocmd FileType ruby setlocal keywordprg=ri

You can also use custom scripts like this one:

#!/bin/bash
#----------------------------------
# file: ~/Scripts/javadocs
#----------------------------------
elinks http://javadocs.org/$1

Just simply change the keywordprg variable to use the script name:

autocmd FileType java setlocal keywordprg=~/Scripts/javadocs
    • #vim
  • 1 year ago
  • 4
  • Permalink
  • Share
    Tweet

I Dig These Posts

  • Post via onethingwell
    Four Word Passwords

    This xkcd cartoon makes a convincing case for using passwords made up of four, easy-to-remember dictionary words instead of...

    Post via onethingwell
  • Link via onethingwell
    FSlint

    FSlint is a utility to find and clean various forms of lint on a filesystem. I.E. unwanted or problematic cruft in your files or file names....

    Link via onethingwell
  • Link via onethingwell
    extundelete

    extundelete is a utility that can recover deleted files from an ext3 or ext4 partition. The ext3 file system is the most common file...

    Link via onethingwell
See more →
  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr