Skip to content

Instantly share code, notes, and snippets.

View corentinbettiol's full-sized avatar

Corentin Bettiol corentinbettiol

View GitHub Profile
@corentinbettiol
corentinbettiol / authors.html
Created December 17, 2019 10:04
Update of the template used to show the latest blog posts by author in a djangocms-blog plugin.
{% load i18n easy_thumbnails_tags %}{% spaceless %}
<div class="plugin plugin-blog">
<h3>{% trans "Authors" %}</h3>
<ul class="blog-authors">
{% for author in authors_list %}
<li><a href="{% url 'djangocms_blog:posts-author' author.get_username %}">
{{ author.get_full_name }}
<span>(
{% if author.count > 0 %}
{% blocktrans count articles=author.count %}1 article{% plural %}{{ articles }} articles{% endblocktrans %}

As of 03/01/20, here's how I install & configure a search box on a djangocms (& djangocms-blog) project using elasticsearch:

TL;DR: It didn't work. Switch to solr.


  1. Make sure to have a fully functional django + djangocms + djangocms-blog project (see djangocms-blog installer).

  2. Install aldryn-search

@corentinbettiol
corentinbettiol / pypi.sh
Created January 15, 2020 15:11
Automatically build & publish package in pypi.
#!/bin/zsh
# 2019 - Corentin Bettiol
# Requires zsh, python3 & twine (python3 -m pip install --user --upgrade twine)
# Licenced under WTFPL v2
trap ctrl_c INT
function ctrl_c() {
echo "Aborting..."

Les infos sur la recherche full-text

Via un soft externe

Directement via la bdd

As of 26/02/20, here's how I install & configure a search box on a djangocms (& djangocms-blog) project using solr:

  1. Make sure to have a fully functional django + djangocms + djangocms-blog project (see djangocms-blog installer).

  2. Install django-haystack & aldryn-search

    1. Run:
      pipenv install git+https://github.com/django-haystack/django-haystack#egg=django-haystack
      
# optional file, see https://github.com/kapt-labs/django-check-seo/wiki/How-to-add-a-check%3F
# Standard Library
import glob
from os.path import basename, dirname, isfile, join
import sys, json
from django.conf import settings
# list files

Publish a project to pypi (doc)

Test

  1. Install twine
python3 -m pip install --user --upgrade twine
  1. Generating distribution archives
@corentinbettiol
corentinbettiol / addshadows.sh
Created March 25, 2020 14:59
Take screenshot from clipboard, add shadow to screenshot, and put it in clipboard.
#!/bin/bash
xclip -selection clipboard -t image/png -o > "screenshot.png"
convert screenshot.png \( +clone -background black -shadow 75x10+0+0 \) +swap -bordercolor none -border 10 -background none -layers merge +repage shadow.png
xclip -selection clipboard -t image/png -i shadow.png
rm screenshot.png shadow.png
@corentinbettiol
corentinbettiol / bouchons.py
Last active October 29, 2020 13:55
Get traffic jams numbers from Ile de France in real time as notifications!
#!/usr/bin/python3
from bs4 import BeautifulSoup
from requests import get
from os import system
from time import sleep
km = "0"
while 1:

List of commands here.

poetry lock && poetry install

Update lock & install dependencies.

poetry show --tree

Output a nice tree of dependencies.

poetry install --remove-untracked

Remove dependencies that are no longer in lock file.