Skip to content

Instantly share code, notes, and snippets.

@victorono
victorono / remove_duplicates.py
Last active April 26, 2024 17:57
Django - remove duplicate objects where there is more than one field to compare
from django.db.models import Count, Max
unique_fields = ['field_1', 'field_2']
duplicates = (
MyModel.objects.values(*unique_fields)
.order_by()
.annotate(max_id=Max('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
@victorono
victorono / CentOS-Base.repo
Created December 4, 2020 13:21
CentOS 6 became EOL on the 30th November, 3 days ago. And all the repos have been archive to https://vault.centos.org/. I have just edited my /etc/yum.repos.d/CentOS-Base.repo file to the below:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
@victorono
victorono / unicode.py
Last active August 1, 2020 21:58
Eliminar tildes string python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unicodedata
def elimina_tildes(cadena):
s = ''.join((c for c in unicodedata.normalize('NFD',unicode(cadena)) if unicodedata.category(c) != 'Mn'))
return s.decode()
string_acentos = 'café'.decode('utf-8')
@victorono
victorono / fix_permissions_plex.sh
Last active July 14, 2020 03:12
plex permissions to access partition mount
sudo gpasswd -a plex plugdev
sudo gpasswd -a plex root
sudo gpasswd -a plex sudo
sudo gpasswd -a plex $(whoami)
sudo gpasswd -a $(whoami) plex
sudo service plexmediaserver restart
@victorono
victorono / pg_search_conf_unaccented.sql
Created July 7, 2020 00:09 — forked from ryanpadilha/pg_search_conf_unaccented.sql
PostgreSQL - full-text search configuration
-- enable extensions
-- full-text search on postgresql
CREATE EXTENSION unaccent;
-- languages supported
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, french_stem;
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english );
@victorono
victorono / install_generic.sh
Created March 12, 2017 02:28
Install all Google Web Fonts onto your local machine
#!/bin/bash
# OS detect
osdetect=$(uname)
file_path="unknown"
if [[ "$osdetect" == 'Linux' ]]; then
file_path="sudo mv fonts/* /usr/local/share/fonts/"
elif [[ "$osdetect" == 'Darwin' ]]; then
file_path="mv fonts/* /Library/Fonts/"
elif [[ "$osdetect" == 'Arch Linux' ]]; then
[
{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } },
{ "keys": ["ctrl+keypad_divide"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+keypad_divide"], "command": "toggle_comment", "args": { "block": true } },
]
@victorono
victorono / gist:d9cb9fa01b38e40a827357a15a5061b1
Created November 1, 2018 02:15 — forked from 345161974/gist:63573abdf1dc9c303d6740fb29496657
Python Code for adding posts to WordPress remotely
import urllib
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
import xmlrpclib
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc.methods import media, posts
import os
########################### Read Me First ###############################
'''
------------------------------------------In DETAIL--------------------------------

Interactive Star Rating Component (CSS Only)

An interactive CSS star rating component.

Has hover and selected states, and could be integrated into a form very easily (as underneath the visual styling it is just radio buttons). Size and margin between the stars can be easily changed by amending the sass variables.

No JS, all CSS and HTML.

Works on IE9>, Chrome, Firefox, Safari

@victorono
victorono / .bashrc
Created May 30, 2015 18:40
Applying Kwin Blur to Transparent Konsole/Yakuake Windows
konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
if [ -n konsolex ]; then
for konsole in $konsolex
do
xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus $konsole /konsole/MainWindow_1 winId`;
done
fi
if [ `qdbus | grep yakuake` ]; then
xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -name Yakuake;
fi