Skip to content

Instantly share code, notes, and snippets.

View Grokzen's full-sized avatar
🏠
Working from home

Grokzen Grokzen

🏠
Working from home
  • Dynamist (https://dynamist.se/)
  • Sweden
View GitHub Profile
#
# extras.urls
#
# Custom Field choices
router.register(r'_custom_field_choices', views.CustomFieldChoicesViewSet, base_name='field-choice')
#
# extras.api.views
#
class CustomFieldChoicesViewSet(ViewSet):
#!/usr/bin/env python
import rediscluster
import uuid
import sys
import time
def create_connection():
startup_nodes = [
{'host': '127.0.0.1', 'port': 7000},
{'host': '127.0.0.1', 'port': 7001},
@Grokzen
Grokzen / reclaimWindows10.ps1
Created January 8, 2017 00:59 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
@@ -397,7 +400,8 @@ class StrictRedis(object):
charset=None, errors=None,
decode_responses=False, retry_on_timeout=False,
ssl=False, ssl_keyfile=None, ssl_certfile=None,
- ssl_cert_reqs=None, ssl_ca_certs=None):
+ ssl_cert_reqs=None, ssl_ca_certs=None,
+ max_connections=None):
if not connection_pool:
if charset is not None:
warnings.warn(DeprecationWarning(
@Grokzen
Grokzen / Symmetrical ManyToMany Filter Horizontal in Django Admin.py
Last active March 12, 2024 17:55
Symmetrical ManyToMany Filter Horizontal in Django Admin
# Based on post from: https://snipt.net/chrisdpratt/symmetrical-manytomany-filter-horizontal-in-django-admin/#L-26
# Only reposting to avoid loosing it.
"""
When adding a many-to-many (m2m) relationship in Django, you can use a nice filter-style multiple select widget to manage entries. However, Django only lets you edit the m2m relationship this way on the forward model. The only built-in method in Django to edit the reverse relationship in the admin is through an InlineModelAdmin.
Below is an example of how to create a filtered multiple select for the reverse relationship, so that editing entries is as easy as in the forward direction.
IMPORTANT: I have no idea for what exact versions of Django this will work for, is compatible with or was intended for.
@Grokzen
Grokzen / sp
Last active August 29, 2015 14:17 — forked from wandernauta/sp
#!/bin/bash
#
# This is sp, the command-line Spotify controller. It talks to a running
# instance of the Spotify Linux client over dbus, providing an interface not
# unlike mpc.
#
# Put differently, it allows you to control Spotify without leaving the comfort
# of your command line, and without a custom client or Premium subscription.
#
@Grokzen
Grokzen / fuzzy.py
Created July 10, 2013 18:13
Tiny lib that will perform a simple version of fuzzy string matching, similar to what sublime text use.
import difflib
def match(key, search_for):
a = [char for char in search_for]
index = 0
for char in key:
if a[index] == char:
index += 1
if index == len(a):