Skip to content

Instantly share code, notes, and snippets.

@victorono
victorono / launch_focus_min.sh
Created October 20, 2016 14:46
To launch an application or to show its window if already launched or to minimize if it is focused
#!/bin/bash
#
# This script does this:
# launch an app if it isn't launched yet,
# focus the app if it is launched but not focused,
# minimize the app if it is focused.
#
# by desgua - 2012/04/29
# modified by olds22 - 2012/09/16
# - customized to accept a parameter
@victorono
victorono / gist:bb48837a3b1a06a69fc6ed24224e1563
Created October 19, 2016 17:40
Spotify segmentation fault Linux
rm ~/.config/spotify -r && rm ~/.cache/spotify -r
[
{ "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 } },
]
# coding=utf-8
import json
from django.contrib import messages
class AjaxMessaging(object):
def process_response(self, request, response):
@victorono
victorono / format_currency.py
Last active June 16, 2016 02:35
format currency
def format_currency(value, decimal_points=3, seperator=u'.', money=u'$'):
value = str(value)
if len(value) <= decimal_points:
return value
parts = []
while value:
parts.append(value[-decimal_points:])
value = value[:-decimal_points]
parts.reverse()
value = "%s %s" % (money, seperator.join(parts))
@victorono
victorono / sort_dates.py
Created March 16, 2016 13:43
Sort list of date strings
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import datetime
all_dates = ['09-2012', '04-2007', '11-2012', '05-2013', '12-2006', '05-2006', '08-2007']
sorted(all_dates, key=lambda x: datetime.strptime(x, '%m-%Y'))
@victorono
victorono / config.txt
Created September 10, 2015 03:52
Raspbian wheezy with XBMC plays only audio for 1080p videos
# You might want to increase your video memory to at least 128 MB. For newer firmware version this can be done by adding the line on "/boot/config.txt"
gpu_mem=128
(possible values: 16, 64, 128, 256) to your
@victorono
victorono / node_js.sh
Last active August 29, 2015 14:22
Install nodejs in mac osx, run as root
# run as root
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
# edit ~/.bash_profile
@victorono
victorono / settings.py
Last active December 13, 2016 22:22
Celery conf
BROKER_URL = 'amqp://user:passwd@127.0.0.1/host'
BROKER_BACKEND = 'amqp'
CELERY_ACCEPT_CONTENT = ['json', 'pickle', 'msgpack', 'yaml']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_IGNORE_RESULT = False
CELERY_RESULT_BACKEND = 'amqp'
CELERY_SEND_TASK_ERROR_EMAILS = True
CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler"
@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