Skip to content

Instantly share code, notes, and snippets.

View niktto's full-sized avatar

Marek Szwałkiewicz niktto

View GitHub Profile
RACES = [
'Dragonborn',
'Dwarf',
'Elf',
'Gnome',
'Half-Elf',
'Halfling',
'Half-Orc',
'Human',
'Tiefling',
@niktto
niktto / models.py
Created August 6, 2015 09:27
Using Django Rest Framework to ease csv generation
from django.db import models
class SomeModel(models.Model):
email = models.EmailField()
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
#!/bin/bash
if [ $ARGUMENT ]; then
if [[ $ARGUMENT =~ .+\.[jpg|JPG] ]]
then
killall eog
eog "$ARGUMENT" -f &
fi
fi
gphoto2 --wait-event-and-download --keep --force-overwrite --hook-script=/full/path/to/show_img.sh
@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
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 / 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
@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 / 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'); }
Kod:
(...)
templates = local()
templates.loaded = {}
def load_builder(builder, template_path):
try:
builder.add_from_string(templates.loaded[template_path])