Index | Archives | Atom Feed

Using More Expressive Types

As a Scala user, I spend a lot of my time thinking about my types. Making good use of types is the key to compile time correctness checking, since compilers are not yet good at checking control flow. For example, consider the following:

def foo1(o: Option[String]) = {
  if(o ...

Refactoring Scala Code From Imperative to Functional

The Scala programming language is unique in terms of FP languages in that it lets you choose your own balance between pure FP and filthy imperative style. This is good and bad, but one benefit is that when you have an algorithm that doesn't immediately translate well into a ...

Why Character Encoding Sucks In Your Language Part 1: Python

Character encoding is one of those topics many software engineers would prefer to have a very minimal understanding of. It's perceived as tricky, uninteresting, and is pretty much an afterthought for most projects that aren't internationalized. This lack of attention leads to tricky bugs that find a way ...

Adding multi-line lambdas to Python

At the risk of this blog becoming dedicated to "the worst things you can do in Python" I present to you: multiline lambdas in Python!

Implementation was simple:

import sys

def fun(string):
    frame = sys._getframe(1)
    out = {}
    locals = {}
    exec ("def __anon ...

Adding functional style pattern matching to Python

One of the nicest features of functional programming languages like Haskell and Erlang is pattern matching. An example, from Learn You Some Erlang:

greet(male, Name) ->
    io:format("Hello, Mr. ~s!", [Name]);
greet(female, Name) ->
    io:format("Hello, Mrs. ~s!", [Name]);
greet(_, Name) ->
    io:format("Hello, ~s!", [Name]).

The ...

wtf php

Here are some things that I hate about PHP:

Non-default arguments are allowed after default arguments, but there’s no way to use them.


 function printabc($a, $b="2", $c) {
     print_r(array('a'=>$a, 'b'=>$b, 'c'=>$c));

 printabc(1,2,3); // normal case

 printabc(4);  // a=>4, b ...

How To Get (Almost) Free Tethering for iPhone (AT&T) No Jailbreak

I commute every day via train and I have several devices to keep me entertained: Kindle (3G but I don’t really use it), iPhone (3G), and laptop (offline). Occasionally I need connectivity for something that my phone isn’t quite good enough for. I don’t want to pay ...

Extending ejabberd with SMS via Twilio (Part 1)

One of my favorite features back when I used to use AOL Instant Messanger was the ability to send messages to any cell phone and basically get SMS messages for free (back before most people had fancy “unlimited” plans). Similarly, I really like the equivalent feature in Gmail that lets ...

© Chad Selph. Built using Pelican. Theme by Giulio Fidente on github. .