Skip to content

Instantly share code, notes, and snippets.

View niktto's full-sized avatar

Marek Szwałkiewicz niktto

View GitHub Profile
@niktto
niktto / qnapi_fix.py
Created May 1, 2012 22:00
Simple script to fix QNapi subtitles
#!/usr/bin/python3
import codecs
import sys
try:
inp = codecs.open(sys.argv[1],'r','cp1250')
except IndexError:
print('You need to give me text file with qnapi subtitles as an argument. Thanks.')
else:
@niktto
niktto / notify.py
Created June 23, 2012 18:23
Sample notification
In [1]: import pynotify
In [2]: pynotify.init("Sample Application Title")
Out[2]: True
In [3]: n = pynotify.Notification("Title", "Message")
In [4]: n.add_action("buttonid", "Happy Button :)", lambda x: x)
In [5]: n.show()
@niktto
niktto / issue_sample.py
Created August 19, 2012 20:12
Issue with default Unity styling
from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_string(
"""
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
Kod:
(...)
templates = local()
templates.loaded = {}
def load_builder(builder, template_path):
try:
builder.add_from_string(templates.loaded[template_path])
@niktto
niktto / style.css
Created December 8, 2012 13:51
sample of css gtk styling for hover
GtkButton.nasz_button { background-image: url('sciezka_do_img'); }
GtkButton.nasz_button:hover { background-image: url('sciezka_do_innego_img'); }
@niktto
niktto / fragment_models.py
Created December 8, 2012 14:02
Problem z okreslaniem kolumn na bazie listy stringów
(...)
class Character(Base):
__tablename__ = 'characters'
uid = Column(Integer, primary_key=True)
session = Column(Integer, ForeignKey('sessions.uid'))
created = Column(DateTime, default=datetime.datetime.utcnow)
name = Column(Unicode(255))
@niktto
niktto / traceback
Created December 14, 2012 12:24
Traceback for error that is occuring when I start my python Gtk3 app on Linux Mint (on Ubuntu 12.04 and 12.10 it works)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
exec code in m.__dict__
File "taskworkshop-light.py", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/gtk3reactor.py", line 22, in <module>
from twisted.internet import gireactor
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/gireactor.py", line 33, in <module>
from gi.repository import GLib
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 27, in <module>
import gi._gobject
LOCK TABLE {table} IN ACCESS EXCLUSIVE MODE;
UPDATE {table} SET status = 1, thread_id = 1
WHERE id IN (
SELECT id FROM {table} WHERE status = 0
ORDER BY creation_date DESC, user_id ASC
LIMIT 100)
RETURNING 'id', 'user_id', 'creation_date', 'modification_date', 'thread_id', 'reason', 'status';
Or from statement log:
@niktto
niktto / basic.py
Last active August 29, 2015 14:04
Sample code for blog post "Write more classes"
class AccountSerializer(serializers.ModelSerializer):
class Meta:
model = Account
fields = ('id', 'account_name', 'user_set', 'created')
depth = 1
gphoto2 --wait-event-and-download --keep --force-overwrite --hook-script=/full/path/to/show_img.sh