Skip to content

Instantly share code, notes, and snippets.

View konradhalas's full-sized avatar

Konrad Hałas konradhalas

View GitHub Profile
#! /usr/bin/env python3
import os
import sys
import subprocess
if len(sys.argv) == 1:
files = os.listdir('.')
else:
files = sys.argv[1:]
@konradhalas
konradhalas / fabfile.py
Created April 25, 2012 18:41
fabfile - simple django app deploy
import os
from fabric.api import run, cd, env, abort
from fabric.contrib.console import confirm
from fabric.context_managers import prefix
from fabric.tasks import Task
env.hosts = ['sample@example.com']
env.settings = ['staging', 'production']
@konradhalas
konradhalas / gist:3504037
Created August 28, 2012 20:41
UserFactory with raw_password
class UserFactory(factory.Factory):
password = 'test'
@classmethod
def _prepare(cls, create, **kwargs):
password = kwargs.pop('password', None)
user = super(UserFactory, cls)._prepare(create, **kwargs)
if password:
user.raw_password = password
user.set_password(password)
@konradhalas
konradhalas / fabfile.py
Created March 18, 2013 22:37
Fabric #367 issue tests.
from fabric.contrib import files
def append():
files.append( '~/append_test', ['line'])
files.append( '~/append test with space', ['line'])
def exists():
print(files.exists('~/exists_test'))
print(files.exists('~/exists test with space'))
@konradhalas
konradhalas / views.py
Last active December 16, 2015 09:48
Simple view wrapper. Now you can convert old, ugly view function into class based view.
from django.views.generic import View
from django.core.exceptions import ImproperlyConfigured
from django.contrib.auth.views import login
class WrapperView(View):
@property
def view_function(self):
raise ImproperlyConfigured("You must define a 'view_function'.")
@konradhalas
konradhalas / utils.py
Created April 19, 2013 07:51
Model instance refresh (reload from DB) function, especially useful in tests.
def refresh(instance):
return instance.__class__._default_manager.get(pk=instance.pk)
@konradhalas
konradhalas / extract_function.py
Created July 22, 2013 19:44
Simple solution how to extract function object from bound method.
def view_example(request):
print(request)
class ViewTestCase(object):
view_function = view_example
def __init__(self):
self.view = self.__class__.__dict__['view_function']
var LICENSE = 'License: For reuse of this video under a more permissive license please get in touch with us. The speakers retain the copyright for their performances.';
var WEBSITE = 'http://summit.pywaw.org';
var result = [];
$(".speaker-modal").each(function() {
var $speakerModal = $(this);
var $talkDetails = $speakerModal.find('.speaker-modal__talk-title');
var speakerName = $speakerModal.find('.speaker-modal__name').text();
var speakerBio = $speakerModal.find('p:not(.speaker-modal__twitter)').first().text();
var mixedTalksDescription = $speakerModal.find('p:not(.speaker-modal__twitter)').slice(1).text();
# return double of first number from collection which is greater than 3 and even
# this is Python 3 srcipt, in Python 2 you have to use itertools.imap and itertools.ifilter
def is_gt_3(number):
print('is_gt_3 called...')
return number > 3
def is_even(number):
print('is_even called...')
return number % 2 == 0

Bardzo krótki poradnik pisania dobrego kodu HTML/CSS

Założenia

Kod HTML/CSS napisany w poprawny sposób powinnien być:

  • semantyczny
  • zorientowany na komponenty
  • łatwy w modyfikacji