Skip to content

Instantly share code, notes, and snippets.

View Deviad's full-sized avatar

Davide P. Deviad

View GitHub Profile
@Deviad
Deviad / models.py
Created May 29, 2017 18:25
models of my flask app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object('config.DevelopmentConfig')
db = SQLAlchemy(app)
class User(db.Model):
__tablename__ = 'users'
@Deviad
Deviad / controllers.py
Created May 29, 2017 18:25
Controllers of my flask app
import pymysql
from flask import Blueprint, request, render_template, json, Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
from app.users_bundle.models import User
from sqlalchemy.orm import sessionmaker
from sqlalchemy.exc import SQLAlchemyError
app = Flask(__name__)
app.config.from_object('config.DevelopmentConfig')
@Deviad
Deviad / __init__.py
Created May 29, 2017 18:24
Flask init
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
from sqlalchemy_utils import database_exists, create_database
from app.users_bundle.controllers import users_bundle
app = Flask(__name__)
app.config.from_object('config.DevelopmentConfig')
db = SQLAlchemy(app)
@Deviad
Deviad / index.html
Created June 22, 2017 08:23
Script for opening tabs from Divi Menu
<script>
var tab = null;
var menuSelector = null;
jQuery(function ($) {
console.log('test');
//howtos tab
function changeMenuSelector() {
if ($( document ).width() > 967) {
menuSelector = 'top-menu-nav';
} else {
@Deviad
Deviad / app_unit_tests_.py
Created July 21, 2017 20:48
Getting out of context error
import json
import urllib
from pprint import pprint
from urllib import request, parse
import pytest
from inspect import getsourcefile
from os import path, sys
current_dir = path.dirname(path.abspath(getsourcefile(lambda:0)))
@Deviad
Deviad / app_unit_tests_.py
Created July 21, 2017 22:52
app_unit_tests_.py:25: in <module> class TestApp(app): ../lib/python3.6/site-packages/flask/app.py:539: in __init__ self.add_url_rule(self.static_url_path + '/<path:filename>', E TypeError: can only concatenate tuple (not "str") to tuple
import json
import urllib
from pprint import pprint
from urllib import request, parse
import pytest
from inspect import getsourcefile
from os import path, sys
current_dir = path.dirname(path.abspath(getsourcefile(lambda:0)))
@Deviad
Deviad / src_ActionTypes.js
Last active August 14, 2017 11:28
I need to know how to make this work with react.It's the official demo from redux-observable
export const FETCH_USER = 'FETCH_USER';
export const FETCH_USER_FULFILLED = 'FETCH_USER_FULFILLED';
export const FETCH_USER = 'FETCH_USER';
export const FETCH_USER_FULFILLED = 'FETCH_USER_FULFILLED';
/*
eslint-disable react/prefer-stateless-function, react/jsx-boolean-value,
no-undef, jsx-a11y/label-has-for, react/jsx-first-prop-new-line
*/
class TimersDashboard extends React.Component {
state = {
timers: [
{
title: 'Practice squat',
project: 'Gym Chores',
@Deviad
Deviad / reactivex.js
Created August 26, 2017 12:53
Import the most needed parts of rxjs in ES6 Using prototype as using webpack it cannot do inference properly on names that are used also by other libraries.
import {Observable} from "rxjs/Observable";
import "rxjs/observable/concat";
import "rxjs/observable/from";
import "rxjs/observable/of";
import "rxjs/add/operator/map";
import "rxjs/add/operator/mergeMap";
import "rxjs/add/operator/startWith";
import "rxjs/add/operator/filter";
import "rxjs/add/operator/switchMap";