Skip to content

Instantly share code, notes, and snippets.

@omeinusch
omeinusch / XboxOneControllerSBluetoothv3.plist
Last active December 29, 2020 22:06
Fixed XboxOneControllerSBluetoothv3.plist - Put file in Steam/steamapps/common/$Game/$Game.app/Contents/Resources/InputDevices/Digital/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CGPDeviceCategory</key>
<string>GamePad</string>
<key>CGPDeviceType</key>
<string>Standard</string>
<key>CGPDeviceImageType</key>
<string>Xbox</string>
def message_object_created(request, obj):
"""
Post a standardized SUCCESSFUL ADDED message to Django's message framework
:param request: incoming HttpRequest
:param obj: object instance which was added
"""
class_name = obj._meta.verbose_name
messages.success(request, _(u'%s <em>%s</em> wurde angelegt.' % (class_name, obj)))
.ellipsis
{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 16em;
}
@omeinusch
omeinusch / create-mysql.bash
Created August 31, 2013 11:50
Simple bash script to create mysql db, user with generated password
#!/bin/bash
PASS=`pwgen -s 40 1`
mysql -uroot <<MYSQL_SCRIPT
CREATE DATABASE $1;
CREATE USER '$1'@'localhost' IDENTIFIED BY '$PASS';
GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost';
FLUSH PRIVILEGES;
MYSQL_SCRIPT
@omeinusch
omeinusch / currency-filter.py
Created May 10, 2013 20:23
Currency-filter for Django's template engine
from django import template
from django.conf import settings
from django.template.defaultfilters import floatformat
register = template.Library()
"""
This little code assumes, that you have a setting named CURRENCY with a value like 'EUR' or 'USD' or u'€'
"""
@register.filter
def currency(value):
@omeinusch
omeinusch / append_urls_to_text_bottom.py
Created June 20, 2012 19:39
Appends all URLs in a given text with numbers surrounded by brackets and returns a tuple with the new text and a dict-list with the urls and their numbers.
def append_urls_to_text_bottom(text):
import re
url_counter = 0
unique_url_list = dict()
appending_list = dict()
url_expression = "(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:/[^\\s]*)?"
list_of_all_urls = re.findall(url_expression, text)
for one_url in list_of_all_urls: