30 Days of Programming

Updating Habitica Habits with Gnome-Pomodoro

Quick little tip for anyone who likes using habitica and also happen to use
Gnome Shell. I’ve been using Gnome-Pomodoro For
scheduling breaks and staying on task. I noticed the app also has support for
Custom actions. This can be really useful to update habitica habits when a pom
has been completed!

So I wrote a little script that will update your Pomodoro Habit
accordingly. It relies on Habitica CLI, so you’ll need to set up your account accordingly follow the instructions on the linked page.

Here’s the quick n’ dirty script:

updatePom.sh []
1
2
3
4
#!/bin/sh
pomHabit=$(habitica habits | grep '<Your Habit Name>' | grep -o '[0-9][0-9]')
notify-send "Pom Habit updated"
habitica habits up $pomHabit

You could also directly call the habitica program from the custom actions
window, but this will let you update/delete habits and still allow the script
to work since it references the habit name and not the habit number (which may change). It’s more of a “set and forget” solution!

Once you have the script, just add it as a custom action:

custom_action.png

Possible Issues:

  • Script only looks for two digit numbers in order to grab the correct habit to
    update, You can change this accordingly. Check out this page for using regex with grep
  • Might break on updates to the habitica CLI

Setting up Hexo to add Per-Post Javascript and CSS

I mentioned earlier that I’d like to be able to seperate Javascript/CSS
in a per-post basis. Well, after some digging I found a solution and thought
it’d be nice to post here.

First, find your themes/your_theme/scripts folder and add
a new *.js file with the following:

1
2
3
4
5
6
7
8
9
10
11
hexo.extend.filter.register('after_init', function () {
// Remove json / js files being inserted to db.json -> Pages
var listSync = hexo.extend.renderer.list(true),
listAsync = hexo.extend.renderer.list();
delete listSync.json;
delete listAsync.json;
delete listSync.js;
delete listAsync.js;
delete listSync.css;
delete listAsync.css;
});

Courtesy of cnotethegr8

Visualizing Sorting Algorithms with D3.js

Hey everyone! The original intent of joining this challenge was, among other things, to really solidify my undergrad courses in a time where I'm between college and a career. I figured, with a few months without much luck on the job front, that something like this would really get me motivated and bulk up on the topics I've learned (or perhaps maybe touched on). Plus, I'm unemployed so what else should I be doing? :) Well, enough explaining myself. Let's get down to it. D3.js is a very nice library for visualizing data. With something like this, I thought it'd be nice to take a stab at writing some interactive sorting algorithm tools. So, if you look at the bottom of the page, you can see what I've come up with so far! I've written a small example program with insertion sort. The easiest of the sorting algorithms! Each time you click the button, it will perform a single step (with very little feedback).

What's next?

Add more sorting algorithms, of course! Also add some feedback to see the current iteration the sorting algorithm is on, clean up the code (I'd like a nicer way of adding javascript that doesn't require inline script tags. I got very comfortable with browserify and node on a previous project, and I want that same level of clean for this site.)