tagging
Union and Intersect in Django
You could use Q objects for #1: # Blogs who have either hockey or django tags. from django.db.models import Q Blog.objects.filter( Q(tags__name__iexact=”hockey”) | Q(tags__name__iexact=”django”) ) Unions and intersections, I believe, are a bit outside the scope of the Django ORM, but its possible to to these. The following examples are from a Django application called … Read more
An easy way to support tags in a jekyll blog
Here is a solution with alphabetically sorted tags on a single page. It uses Liquid only, which means that it works on GitHub Pages: {% capture tags %} {% for tag in site.tags %} {{ tag[0] }} {% endfor %} {% endcapture %} {% assign sortedtags = tags | split:’ ‘ | sort %} {% … Read more
Understanding Gitlab CI tags
Tags for GitLab CI and tags for Git are two different concepts. When you write your .gitlab-ci.yml, you can specify some jobs with the tag testing. If a runner with this tag associated is available, it will pickup the job. In Git, within your repository, tags are used to mark a specific commit. It is … Read more
How to get last Git tag matching regex criteria
I’m using the following command for this: git describe –match “v[0-9]*” –abbrev=4 HEAD It will also modify the version if you did something with the source tree since your last versioned tag. Please note that this is not a regex but a glob but works for the provided example.
Validate the number of has_many items in Ruby on Rails
A better solution has been provided by @SooDesuNe on this SO post validates :tags, length: { minimum: 1, maximum: 6 }
TTL for a set member
No, this isn’t possible (and not planned either). The recommended approach is to use an ordered set with score set to timestamp and then manually removing expired keys. To query for non-expired keys, you can use ZRANGEBYSCORE $now +inf, to delete expired keys, ZREMRANGEBYSCORE -inf $now will do the trick. In my application, I simply … Read more
How to implement tag system
I believe you’ll find interesting this blog post: Tags: Database schemas The Problem: You want to have a database schema where you can tag a bookmark (or a blog post or whatever) with as many tags as you want. Later then, you want to run queries to constrain the bookmarks to a union or intersection … Read more
How do you revert to a specific tag in Git?
Git tags are just pointers to the commit. So you use them the same way as you do HEAD, branch names or commit sha hashes. You can use tags with any git command that accepts commit/revision arguments. You can try it with git rev-parse tagname to display the commit it points to. In your case … Read more
What is the most efficient way to store tags in a database?
One item is going to have many tags. And one tag will belong to many items. This implies to me that you’ll quite possibly need an intermediary table to overcome the many-to-many obstacle. Something like: Table: Items Columns: Item_ID, Item_Title, Content Table: Tags Columns: Tag_ID, Tag_Title Table: Items_Tags Columns: Item_ID, Tag_ID It might be that … Read more