Home / Blog Menu ↓

Blog: #coding

91 posts / tag feed / about the blog / archive / tags

Lifter is “a lightweight query engine for Python iterables.” Looks nice. One of their examples:

# vanilla Python
results = [
    user for user in users
    if user['age'] == 26 and user['is_active']
]

# lifter
results = manager.filter(User.age == 26, User.is_active == True)

Reply via email

Neovim 0.1.0

Neovim 0.1.0 was released yesterday. I’ve been using an earlier version for a month or two now and all things told, I’m happy with it. My old .vimrc worked fine (though with 0.1.0 the .vimrc has been moved to ~/.config/nvim/init.vim, which will take a bit of getting used to), and everything I’ve needed to use has worked. Vim-plug is nice for managing plugins. I haven’t switched from Syntastic to Neomake yet, but that’s on my todo list for the near future.


Reply via email

Asteroids

Earlier this week I wrote a small Asteroids clone in JavaScript:

Video of the game

Instructions and the link to the game are on the project page.

FYI, here’s how I made the animated GIF: I used Quicktime Player to record a portion of the screen, then used ImageMagick to convert the .mov file to a series of PNGs:

convert asteroids.mov png/asteroids_%03d.png

I deleted the extra frames at beginning and end that I didn’t care about (unpausing the game, figuring out how to turn the recording off), then used ImageMagick again to make the GIF:

convert -delay 1x30 png/*.png -layers optimize +dither -colors 32 asteroids.gif

Reply via email

Momentum

I’m getting back into blogging about in-progress projects, because otherwise I hardly blog at all. Expect posts soon about the following coding projects, all at varying stages of completion:

  • Vinci (notebook app)
  • Bookshelf (successor to Bookkeeper)
  • Codex (successor to Unbindery)
  • Quill (successor to Codex, sort of)
  • Storybook (writing app)
  • Speed (desktop writing app)
  • Liszt (todo list app)
  • Endless (mindmapping app)
  • Botswana 2 (revamp of Botswana)

Brief sidenote: I switched a while back to Python/Django, and I’m very glad I did. I can often get to a working prototype within only an hour or two. Back in my younger days I wanted to write everything myself from the ground up, but I see now that I was foolish. Life is short. I’d rather focus on the interesting parts — the app itself — and let the framework handle the routine grunt work.

Momentum

Momentum is the app I’d like to introduce today. It’s a web app written in Django, started back in January to help me track my goals.

More specifically, I wanted something that would help me spend more time reading scriptures and writing fiction. I don’t always have a free half-hour, though, so I needed something to track little bits of time throughout the day, and Momentum was born. I’ve been using it pretty much every single day since then.

Here’s what it looks like on my phone (with dummy data):

momentum.png

Some quick notes:

  • It currently supports tracking minutes, times, or words per day.
  • When I reach a particular goal, it disappears from the list for the rest of the day so I can focus on the goals I haven’t yet reached. (This is a change I made last night, actually.)
  • If I don’t make any progress toward a goal at all within a set time period, the goal goes stale and turns red. (There’s a system-wide stale period setting and each goal can also have its own.) I started using this staleness idea in Bookshelf (more on that in a later post) and it’s been motivating enough that I ported it to Momentum.
  • It supports folders. I have Projects and Health folders, where I have specific projects (stories/apps I’m working on), and things like squats and pushups.
  • Right now you have to add/edit goals via the Django admin. It works but isn’t as nice as something in-app. I just need to get around to doing this, since this is the main thing keeping it from being releasable.
  • The code is on GitHub as usual. Again, this is unreleased, in-progress code, YMMV, grain of salt, etc.

Reply via email

Xcode 7 apps on device

I was excited to see this: with Xcode 7, Apple now allows people to run their custom apps on their own devices without having to pay the $99/year membership fee:

Now everyone can get their app on their Apple device.

Xcode 7 and Swift now make it easier for everyone to build apps and run them directly on their Apple devices. Simply sign in with your Apple ID, and turn your idea into an app that you can touch on your iPad, iPhone, or Apple Watch. Download Xcode 7 beta and try it yourself today. Program membership is not required. (link)

This is perfect for me. I’ve long wanted to write apps for my own use, but because I don’t have any interest in selling them, the $99/year felt like a superfluous cost. (I also have a strong aversion to monthly subscriptions.)

Time to learn Swift…


Reply via email

Gent

For a while I had been itching to have a better way to track genealogy research todo items — something that organizes items by family and links back to Family Tree, mainly. And thus Gent was born:

Gent.png
Gent-2.png

I’ve been using it for a couple months now and really like it. Before, I felt disorganized and didn’t know where all my notes were; now, even if I come back to my research after a month or two away, it’s easy to get back into it.

The app is built on Django (Python), and I’m calling it a 0.1 release since there are almost certainly bugs I haven’t found. But it does work for me. (For what that’s worth.)


Reply via email

Unicode Inspector

I’ve lately had the need to find what the code points are for some Unicode text, so I wrote a little web app:

Basically, you type in text and it tells you what the Unicode hex codes are. Pretty simple. There’s a live version on GitHub.

Nerdy notes

  • I’m using punycode.js to do the conversion.
  • I haven’t yet tested it with anything above U+FFFF.
  • Firefox shows the dotted circle for combining marks, but Chrome sadly doesn’t. (Which is why I used Firefox for the screenshot.)
  • At some point I’d like to add more information about the characters — Unicode name, classification, link to chart, etc.

Reply via email

Fledge

Introducing Fledge, a file processing language/shell written in Python. I wrote it for two reasons: first, as an experiment with an idea that I’ll explain in a moment, and second, because I can’t for the life of me ever remember how to do batch find-and-replace in text files on the command line. (And yes, I could have written a script to help me with the latter. In fact, I did. I just can’t ever remember what it’s called. I … may have issues.)

Anyway, the idea is that you select the files first, then execute one or more actions on them, rather than the normal way round. For example:

with my-book.text
split on /CHAPTER/ to chapter-%%.text
replace /CHAPTER/Chapter/
trim

That splits my-book.text out on a regex to chapter-01.text, chapter-02.text, etc., does a batch find-and-replace on all those chapter files, and then trims them of whitespace at the beginning and end of each file. The alternative would be something like this, assuming you had split, replace, and trim scripts:

$ split my-book.text "/CHAPTER/" "chapter-%%.text"
$ replace chapter-*.text "/CHAPTER/Chapter/"
$ trim chapter-*.text

So, instead of having to specify which files you’re working on at every step of the way, with Fledge you just do it at the beginning and that selection is used for whatever subsequent actions you perform.

Some more examples

with *.jpg where size != 0
rename page-%%%.text starting with 0

This gets all the non-zero image files in the directory and renames them sequentially to page-000.jpg, page-001.jpg, etc.

alias {mtp} ~/Documents/mtp
with **/*.jpg
convert to png
deselect DSC*
move to {mtp}

This finds all the JPEG files recursively under the current directory, converts them to PNG, deselects everything that starts with DSC, and moves the rest of the PNGs to ~/Documents/mtp.

More about Fledge

The fl script can either execute a script of Fledge actions contained in a file or, if you run it without arguments, it loads an interactive shell.

There are a number of built-in Fledge actions (listed in the README), mostly geared towards working with text and image files, but you can write custom actions (which live in ~/.fledge/actions) to do pretty much anything. (Keeping in mind that in general these would be things you want to do to a large number of files.)

How I’m using it

I use it to help prep image scans of journals and personal histories and stuff to upload to Unbindery for transcription (which, incidentally, I’ve been thinking about paring down to a much simpler, more focused app aimed at family history transcription). I also use it for ebook production (splitting Project Gutenberg files into chapters to be made into EPUBs, doing batch substitutions, etc.) and for Mormon Artist (resizing and renaming images, mostly).

So far, I like it. It’s still very much a work in progress (as I write this I’m realizing rename probably should be rename to for consistency), but I can actually remember these commands. And for situations where I’m doing a lot of sequential actions on multiple files (as in ebook production), it’s nice not having to re-specify everything every step.


Reply via email

Shortform initial draft

After blogging that Shortform mockup, I kept finding myself needing the app itself, so I went ahead and started writing it. It’s very much a draft and not polished, but the core is there, and it’s usable enough that I turn to it quite often.

What’s working

  • You can create notes.
  • Notes are autosaved to a folder specified in preferences.
  • Notes are reopened when you open the app, like with Stickies.
  • User-customizable global hotkeys (using MASShortcut):
    • Show app
    • Create new note
    • Create new note with the contents of the clipboard

What’s not implemented yet

  • Console. I made a first failed attempt (which messed all the window layout up) and need to try again.
  • Title bars. I’ve decided I don’t actually want them — they look nice, but since you can drag a note using the margin on any side of the window, and since you can use keyboard shortcuts or the menu item to close the current note, the title bars aren’t really necessary.
  • Preview mode.
  • Themes.

Note that this is my first OS X app, so I’ve undoubtedly flubbed a number of things. But I do have to say that Cocoa is a very nice framework to work with — I was able to get to this point far more quickly than I expected to. And Objective-C is — dare I say it — growing on me a little.


Reply via email

Shortform mockup

Lately I’ve been itching for a way in OS X to quickly create temporary sticky notes but with Markdown support and with decent text processing (regex find-and-replace, etc.) and with the ability to type first and act later (like Drafts for iOS). The default Stickies app doesn’t really fit the bill (and it isn’t pretty).

So I’ve mocked up an OS X app I’m calling Shortform:

I don’t know if I’ll actually write the app (Cocoa learning curve and other pressing needs, etc.), but since the likelihood of someone else writing it is very small, that may have to be what happens. Things of note:

  • Console and reusable actions. In the upper left note, you can see a console at the bottom. It’s a command line for text editing, basically. There’d be built-in commands (like replace or trim or what have you) along with ways to send the text elsewhere (email and web services being the two main ones I’d use). You would also be able to save a sequence of commands into a reusable action.
  • Keyboard shortcuts. Lots of configurable shortcuts — new note, new note with clipboard contents automatically pasted in, shortcuts for custom actions, etc. And a global shortcut to focus the app.
  • Markdown preview. The middle note (with the green header) shows a preview (processed through Markdown to HTML with some CSS). I’m thinking notes could be in either edit mode and preview mode, rather than having two separate windows.

How I think I’d use Shortform:

  • Quick text processing. I often need to do a quick regex on a snippet of text — adding hyphens to the beginning of a list of things, for example.
  • Temporary notes while I’m working on something. Stuff I need to write down but don’t care to keep in a longer-term notebook. That’s how I use Stickies right now.
  • Quick entry for blog posts, etc. I love Drafts on iOS. Type first, then do what you need to do with it. It’s particularly useful with web services — I can type a note, then send it to whichever one of my Vinci notebooks I want.

Anyway, at this point it’s just a mockup. If I do end up building it someday, I’ll let y’all know.


Reply via email