Skip to content

Instantly share code, notes, and snippets.

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

Jani Šumak dasdachs

🏠
Working from home
View GitHub Profile
@dasdachs
dasdachs / sicris_scraper.py
Last active May 30, 2017 16:04
A simple scraper for sicris.si
# -*- coding: UTF-8 -*-
#! usr/bin/python3
__author__ = "Jani Šumak <[email protected]>"
__version__ = "1.0"
import datetime
import logging
import json
import time
@dasdachs
dasdachs / csv_to_flask.py
Created July 24, 2016 13:14
Upload, read and save the content of a csv file to your model
#!/usr/bin/env python
from io import TextIOWrapper
import csv
from flask import Flask, request, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
# Create Flaskk app, config the db and load the db object
# http://flask-sqlalchemy.pocoo.org/2.1/quickstart/#a-minimal-application
@dasdachs
dasdachs / wagtall_save_image_from_shell.py
Created June 20, 2016 14:27
Save an image from the shell or programatically to Wagtail.
# Save an image from the shell or programatically to Wagtail
# If you are using a cutom Image model, please import your model
import os
from django.core.file import File
from wagtail.wagtailimages.models import Image
def save_image_to_wagtail(image):
"""
@dasdachs
dasdachs / urls_from_css.py
Created March 17, 2016 07:14
Python - get URLs from CSS
def get_urls(css_file):
"""
Get all URLs from a CSS file with regex pattern matching.
URI's, like data URIs are ignored and URLs might be relative.
:param css_file: a string representing the CSS file (use open()
and read() or a request library to get the string)
:return: list with retrived urls
"""