Skip to content

Instantly share code, notes, and snippets.

View tim-hub's full-sized avatar
:octocat:
Patience is Love

Tim tim-hub

:octocat:
Patience is Love
View GitHub Profile
@tim-hub
tim-hub / gist:71c263203b55a91a531e5def1aabd770
Created December 29, 2016 02:26 — forked from skyuplam/gist:ffb1b5f12d7ad787f6e4
Flask-Security and Flask-Admin example by Steve Saporata
# Example of combining Flask-Security and Flask-Admin.
# by Steve Saporta
# April 15, 2014
#
# Uses Flask-Security to control access to the application, with "admin" and "end-user" roles.
# Uses Flask-Admin to provide an admin UI for the lists of users and roles.
# SQLAlchemy ORM, Flask-Mail and WTForms are used in supporting roles, as well.
from flask import Flask, render_template
from flask.ext.sqlalchemy import SQLAlchemy
@tim-hub
tim-hub / uikit offcanvas hide and show.html
Created January 14, 2017 09:21
uikit offcanvas example, with hide the offcanvas and the nav parent and sub example
<div id="offcanvas_side_nav" class="uk-offcanvas">
<div class="uk-offcanvas-bar uk-offcanvas-bar-flip">
<div class="uk-offcanvas-bar">
<ul class="uk-nav uk-nav-offcanvas uk-nav-parent-icon" data-uk-nav>
<li class="uk-nav-header">
<a class="button_link_like"
id="turn_off_offcanvas"
@tim-hub
tim-hub / using_gridfs.py
Created January 25, 2017 07:44
mongodb use gridfs pymongo
#!/usr/bin/env python
import pymongo
import gridfs
# establish a connection to the database
connection = pymongo.MongoClient()
#get a handle to the test database
db = connection.test
@tim-hub
tim-hub / see.sh
Created February 19, 2017 08:51
see mongod running
ps -ef | grep mongod
import pymongo
import sys
c = pymongo.MongoClient(host=["mongodb://localhost:27017",
"mongodb://localhost:27018",
"mongodb://localhost:27019"],
replicaSet="m101",
w=1,
j=True)
@tim-hub
tim-hub / handle_update_failover.py
Last active February 21, 2017 07:59
insert to replica set, and catach errors
#!/usr/bin/env python
"""
Updates documents in a safe manner and catches expected errors.
"""
import pymongo
import time
# Previous code; left here for reference.
@tim-hub
tim-hub / flask run.sh
Last active March 11, 2017 08:00
run flask app locally redhat cloud openshift
export FLASK_APP=wsgi.py
export FLASK_DEBUG=1
flask run
// Unity C# Cheat Sheet
// I made these examples for students with prior exerience working with C# and Unity.
// Too much? Try Unity's very good tutorials to get up to speed: https://unity3d.com/learn/tutorials/topics/scripting
@tim-hub
tim-hub / Redis Cluster Flask Cache.md
Created April 28, 2017 07:59 — forked from Richard-Mathie/Redis Cluster Flask Cache.md
Redis Cluster plugin for Flask Cache

Flask Cache Redis Cluster Backend

This impliments a redis cluster backend for Flask-Cache as the standard redis cache cannot handle a redis cluster.

Usage

class Config(object):
@tim-hub
tim-hub / vue-custom-input-component-exercise.js
Created May 10, 2017 05:45 — forked from laracasts/vue-custom-input-component-exercise.js
vuecasts.com - Custom Input Components exercise.
Vue.component('coupon', {
props: ['code'],
template: `
<input type="text"
:value="code"
@input="updateCode($event.target.value)"
ref="input">
`,