Link
Here are a few examples of what you could add to the Looking For section on Sparkboard. We’ll be sure to review it periodically and help in any way we can!
Connections to early user groups. For instance, a past HH group was connected to the mental health association in BC.
Assistance with...
1 note
·
View note
Text
IfRaise - Useful python snippet
I don't know for you but it seems that this pattern happens again and again to me:
def get_user(username): try: return User.objects.get(username=username) except User.UserNotFound: return None
I find it too verbose and wanted a way around that. So, I've created a small decorator. Here's how it works:
@IfRaise(User.UserNotFound, None) def get_user(username): return User.objects.get(username=username)
(If the exception User.UserNotFound is raised, we return None instead)
We could also have used something like:
class HighLevelException(Exception): pass @IfRaise(User.UserNotFound, HighLevelException()) def get_user(username): return User.objects.get(username=username)
where the HighLevelException would have been raised instead of User.UserNotFound. Changing the type of the exception is useful to make interface cleaner. For instance, in a module, you usually don't want to raise a DivideByZeroException; you'd rather throw a InvalidArgument or a higher level exception to better encapsulate the function. Anyhow, check it out on github: https://github.com/phzbox/IfRaise
0 notes
Text
Easily change tasks by using filters
As posted earlier, while using TaskWarrior, I often want to change tasks based on a filter.
For instance, I'd like to do:
task due:tomorrow due:2nd
(meaning: change all tasks tare are due for tomorrow and make them due for the 2nd)
Sadly, as of now, I'm not sure how to do this.
Here's an attempt:
task list due:tomorrow task 1-5 due:2nd
But, manually typing all the IDs is annoying and error-prone.
Here's a temporary solution until I find something better :)
task `tf due:tomorrow` due:2nd
tf is a little script that returns the ids matching "due:tomorrow".
# tf task id "$@" | grep -E '[0-9]+$'
However, task id is not a builtin command, we need to manually create a report for it.
Add this in ~/.taskrc:
report.id.description=Only ids report.id.columns=id report.id.filter=status:pending
What it does is only show the IDs matching a filter.
The reason I didn't simply parsed 'task list' is to avoid confusion with metadata and others stuff unnecessary displayed by the 'list' command.
Of course, do not forget to add this script to your PATH and make it executable (chmod +x tf)
Now, it's really easy to change tasks related to a date or a project such as:
# Add the tag urgent on all tasks due for tomorrow in the project my-project
task `tf pro:my-project due:tomorrow` +urgent
0 notes
Text
Stop tasks when laptop is closed
Recently, I've been having some fun trying out the TaskWarrior todo application. Using rlwrap and tilda, adding and managing tasks have never been so easy. However, an important feature was missing: Stop counting time when I close the lid of my laptop.
Here's how I managed to solve that problem:
task active | grep '*' | awk '{print $1}' | xargs task stop
(Which basically gets all the ID of the tasks still active and stop them.)
Maybe there is a better/simpler way to do that using only TaskWarrior? I've searched and read the man but found nothing. I might create a little script to make filtering tasks easier in the future. For instance:
# tf is for TaskFilter task stop `tf active` # or task `tf pro:xyz` due:tomorrow
But ideally, it'd be awesome if the TaskWarrior team would add such a feature :)
Finally, to make this little script work, I had to change my: /etc/acpi/handler.sh file and add:
su - phzbox -c stoptasks
Why the "su - phzbox"? Because otherwise "task" would would be executed as root (which has no tasks pending..).
0 notes