OhMyZsh has some awesome extensions and I particularly liked the Git one. Based on the idea, I made a Mercurial lib which shows the current info about the folder we're in.
The Android extension prints some data from the AndroidManifest file - package name and minimum Android version for now. I suck a bit at shell scripting, so it's based on xmlstarlet instead of grep/awk/sed leet magic.
Looks cool, doesn't it? You can find it all in My fork of OhMyZsh. Check out my theme file so you get an example of how you can implement them in your theme.
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user='%{$fg[green]%}%n%{$reset_color%}'
local user_host='%{$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
local hg_info='$(hg_prompt_info)'
local android_info='$(android_prompt_info)'
PROMPT="╭─${user} ${current_dir} ${android_info}${git_branch}${hg_info}
╰─%B$%b "
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
ZSH_THEME_HG_PROMPT_PREFIX=$ZSH_THEME_GIT_PROMPT_PREFIX
ZSH_THEME_HG_PROMPT_SUFFIX=$ZSH_THEME_GIT_PROMPT_SUFFIX
ZSH_THEME_ANDROID_PROMPT_PREFIX="%{$fg[green]%}‹"
ZSH_THEME_ANDROID_PROMPT_SUFFIX="› %{$reset_color%}"
I like Flickr for the ability to organize loads of photos in an efficient way. One thing that always struck me is the lack of customization of your photostream - no themes, no custom domains. To get a sense of personal feeling I decided to grab my photos and incorporate them into my private website. Negotiating various use cases with myself, finally I decided to mirror all my photo data into a Django app. Here it is.
I built this project to generate a self-hosted photoblog using Flickr as storage (free hotlinks, yay). It replicates your Flickr photos database (currently photos and photosets, collections comming soon) to Django models and provides management commands to sync your Django app with your Flickr content.
I'm going to write a command to download the actual files so it could be used as a backup tool. Actually that was the first plan, but I got a bit carried away.
source on BitBucket https://bitbucket.org/zalew/django-flickr
package in cheeseshop http://pypi.python.org/pypi/django-flickr/
instructions on wiki https://bitbucket.org/zalew/django-flickr/wiki/Home
You can see it in action in the photo section right here.
Usage is pretty simple and all can be done with a management command, f.ex.:
$ ./manage.py flickr_sync --page=1 --per-page=30
$ ./manage.py flickr_sync --days=2
Check project's page for details and for the latest code. You're welcome to fork it and participate in development.
HackerNews doesn't have any official public API. Looking for a way to grab my saved stories archive I've recently found Nick Sergeant's HN Python script. It works via screenscrapping and usage is pretty straightforward:
$ hackernews.py saved -u 'username' -p 'password'
I forked it and made some slight improvements, so it grabs the HN url and date when the story was posted. Also it's now a bit easier to use it as a Python module.
To see it in action check out the HN section of my blog. Since we're here, there you have the actual Django code that handles it:
class HN(models.Model):
title = models.CharField(max_length=255)
url = models.URLField(max_length=255, verify_exists=False)
date_posted = models.DateField()
hn_url = models.CharField(max_length=20)
class Meta:
ordering = ('-date_posted', '-id',)
def __unicode__(self):
return self.title
def get_absolute_url(self):
return self.url
You have to provide HN_USER and settings.HN_PASS in your project settings.
from blog import hackernews
from blog.models import HN
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from optparse import make_option
import json
import os
import time
class Command(BaseCommand):
help_text = ''
option_list = BaseCommand.option_list + (
make_option('--all', '-a', action='store_true', dest='all', default=False, help='grab all.'),)
def __init__(self):
super(Command, self).__init__()
def handle(self, *args, **options):
result = hackernews.saved(username=settings.HN_USER, password=settings.HN_PASS, all=options.get('all', False))
data = json.loads(result)
for site in reversed(data):
print site['hn_url'], site['title']
hn, cr = HN.objects.get_or_create(title=site['title'], url=site['url'], hn_url=site['hn_url'], date_posted=site['date_posted'])
return 'Sync end'
$ ./manage.py hn_sync
I am a programmer from Warsaw, Poland.
I specialize in building dynamic web applications. If you need coding or consulting work for your online projects, feel free to contact me.
hosting: megiteam.pl