Trending
Heat Index
Python
Most Recent
 
Read More
July 23, 2020

Quick and easy datatables with jquery

You want a nice looking, easy to use, table to display some data.

You can spend some time custom coding the table with various sorting functions and perhaps hiding the odd column but that’s all done for you already. Using Jquery Datatables.

I will show a couple of quick examples on how I now use the datatables Jquery plugin to quickly be able to control various functions of the table to make it simple and easy to use.

First off you include the two required files, A Css file and a JS file.

//cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css //cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js

Then you can just include one piece of js code [...]

393
 
Read More
April 26, 2020

How to use Blueprint static folders correctly in Python – Flask

In a sentence. Static folders don’t inherit as templates do. Ill explain.

In Flask you have a concept called Blueprints.

In most Flask tutorials you see throughout the web they will have a single file which contains everything including your routes, models and any other code. You may do some includes to pull in additional functions but that is probably it.

As your Flask application grows in size this is obviously not feasible and the different sections of code need to be separated out into different folders or separations of concerns as it were.

For this, you can use Blueprints. you create a folder for example /lists/ and in there you define an [...]

3742
 
Read More
February 26, 2020

Python Flask SQLalchemy Mixins at the end of existing columns

A mixin can add specific fields to another model in Flask,

Example model

# User Class class User(db.Model): __tablename__ = 'User' id = db.Column(Integer, primary_key=True) username = db.Column(String(32), unique=True) email = db.Column(String(32), unique=True) password = db.Column(Binary) role = db.Column(String(32), default="Member") # Define the relationship to Role via UserRoles def __init__(self, **kwargs): for property, value in kwargs.items(): # depending on whether value is an iterable or not, we must # unpack it's value (when **kwargs is request.form, some values [...]
974
 
Read More
February 11, 2018

Damn Regex isn’t hard I just cant remember it.

I have learned and forgotten regex about 30 times now. The following are my notes while I learn again so I can refer back to it.

Basic Regex Matching

To match a string you can just type in the actual string you want to match so to match

Cat you can just type in cat as the regex and it will match

\d matches any digit from 1 to 9. the preceding slash is the escape symbol in regex

The . is a wildcard and matches anything including whitespace so to match three chars and a 4th char which is a full stop ie “htb.” you can use …\. escaping the last one. this matches any three characters and then a .

inside square brackets you can match [...]

51
Latest Headlines
 
 
 

Trending Topics
Web
Python
Flask
Uncategorized
valve
sqlalchemy
Jquery
wordpress
Tech
Top Stories
 
 
 
 
 
 
 
 
Right Now
 
 
 
 
 
 
Top Five
Heat Index
 
1
How to use Blueprint static folders correctly in Python – Flask
 
2
How to forward emails to Freshdesk correctly in Office Exchange 365
 
3
Hass.io Homeassistant Rfxtrx setup for LightwaveRF Devices
 
4
Nginx proxy caching with multiple php pools and WordPress
 
5
Python Flask SQLalchemy Mixins at the end of existing columns