Skip to content

Instantly share code, notes, and snippets.

View wooyek's full-sized avatar
🏠
Working from home

Janusz Skonieczny wooyek

🏠
Working from home
View GitHub Profile
@wooyek
wooyek / twon-mobile302.js
Created August 9, 2019 15:16
Kod odpowiedzialny za przekierowanie do strony mobilnej na stronach TWON
var getCookie = function(name) {
var val = "; " + document.cookie;
var parts = val.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift()
};
var handheld = (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent || navigator.vendor || window.opera) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go
@wooyek
wooyek / config.fish
Created June 27, 2018 19:10
Fish Shell config for completions and stuff
set -x PATH "/home/$USER/.pyenv/bin" $PATH
set -x PATH "/home/$USER/.local/bin" $PATH
set -x PATH "/data/opt/google-cloud-sdk/bin/" $PATH
status --is-interactive; and source (pyenv init -|psub)
# source (env SHELL=fish pew shell_config)
source (vex --shell-config fish|psub)
# pip completion --fish > ~/.config/fish/completions/pip.fish
# source (pip completion --fish|psub)
@wooyek
wooyek / interview.py
Created September 16, 2016 09:29
Django interview task
# Make this test pass.
# Make sure the get method is tested and leave the assertions as they are.
from django.contrib import messages
from django.contrib.messages import constants
from django.http import HttpRequest
from django.http import HttpResponse
from django.test import SimpleTestCase
from django.views import View
@wooyek
wooyek / detail.html
Created April 8, 2016 17:35
This is programmer being lazy. 30 minutes of coding because 5 minutes oc copy paste was just to much work.
{% block content %}
<table class="table table-striped">
{% for field_name in ['name', 'sector', 'size', 'email', 'phone', 'url', 'address'] %}
<tr>
<th>{{ object.get_field_name(field_name) }}</th>
<td>{{ object[field_name] }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
#coding=utf-8
import random
import json
try:
with open("imiona.json") as f:
imiona = json.load(f)
print(u"Wcześniej zapisane imiona")
for imie in imiona:
print(imie)
@wooyek
wooyek / relative_templates.py
Last active August 29, 2015 14:03
A jinja2 extension allowing to import relative template names
# coding=utf-8
# Created 2014 by Janusz Skonieczny
from jinja2.ext import Extension
import re
class RelativeInclude(Extension):
"""Allows to import relative template names"""
tags = set(['include2'])
@wooyek
wooyek / manage.py
Created December 6, 2013 17:07
Babel CLI wrapper for Flask-Script
# coding=utf-8
import logging
import sys
from main import app
from flask_script import Manager, Command
manager = Manager(app)
@wooyek
wooyek / requirements.txt
Created July 21, 2013 22:31
Podstawowe biblioteki dla aplikacji Django
Django==1.5.1
PyYAML==3.10
South==0.8.1
-e git://github.com/django-debug-toolbar/django-debug-toolbar.git#egg=django-debug-toolbar
django-extensions==1.1.1
mock==1.0.1
six==1.3.0