Other articles


  1. Copying Arrays in Julia

    By default, Julia will copy an array by reference. This means that if you change any values in the copy, the original will also change. For example:

    > x = [1, 2, 3]
    > z = x
    > z[1] = 10
    > print(x)
    [10, 2, 3]
    

    You can avoid this by using copy():

    > x = [1 …
    read more
  2. Regular Expressions with Julia

    I had briefly used regular expressions, to check the format of a string, on a previous day. I got into a bit more for today's task, where there were a lot of inputs of the form:

    light orange bags contain 1 dark maroon bag, 3 dim maroon bags, 5 striped …
    read more
  3. Advent of Code with Julia

    I enjoy Advent of Code every year. I like the small daily puzzles, and I certainly wouldn't want anything long and complicated every day. However, in order to add a bit of challenge, without resorting to racing, this year I'm using a language I don't really know. That's right, it's …

    read more
  4. XMonad Configuration Notes

    I made a disastrous attempt at upgrading my Ubuntu distribution today. It failed partway through, leaving things in a horrible broken state. I use XMonad as my windows manager, mostly because I hate having to move things around with a mouse. But today it especially paid off, because the half-upgraded …

    read more
  5. The Sneaky Modulo Operation

    Suppose you need to know if a given number is a multiple of, say, 5. There's a simple solution to this problem: the modulo operator. In many languages, it looks like this:

    x % 5
    

    And what it returns is the remainder when dividing x by 5. If that remainder is …

    read more
  6. Iterating Through a List and Deleting Elements

    Suppose you're iterating through a list, and you want to remove elements under some condition. This seems pretty easy: you've got an element, and python lists have a remove method that you can call with that element.

    However... let's try it with a simple example:

    >> mylist = range(10)
    >> for x …
    read more
  7. Julia

    I had planned to write a blog post about how great Julia is. I spent many years using Matlab, both in grad school and in finance. Since then, I've been using NumPy for mathy things, but it feels really awkward, since it's just sitting on top of another language, with …

    read more
  8. Avoiding Repetitive Methods

    We all know that you should avoid writing the same code over and over: put it in a function and just call that function whenever you need it. But what if what you need is a class with a whole bunch of really similar methods, each with a different name …

    read more
  9. Default Arguments in Python

    In Python, you can assign a default value to an optional varible like so:

    def myFunction(x, y = 0):
        print x + y
    

    myFunction can be called with either one or two arguments. If only one argument is supplied, y will have a value of 0.

    This is all perfectly straightforward …

    read more
  10. Uploading files using Twisted Web

    Inputting information through web forms is really easy under Twisted web. You just have to set up render_GET to display a form, where each input element has a name (e.g. "name", "email", whatever). Then, render_POST, taking an argument of request, can access these values as follows:

    name = request.args …
    read more

social