Skip to content

Instantly share code, notes, and snippets.

@gouthambs
gouthambs / dbutils.py
Created January 15, 2019 14:59
Database utilities, including connection strings to pyodbc or turbodbc etc..
import sqlalchemy
import os
def get_mssql_turbodbc_engine(server, database):
conn = "mssql+turbodbc://{0}/{1}?trusted_connection=yes;driver=ODBC+Driver+13+for+SQL+Server".format(server, database)
return sqlalchemy.create_engine(conn)
def get_mssql_pyodbc_engine(server, database):
@gouthambs
gouthambs / LICENSE.TXT
Last active February 14, 2018 22:52
Serverless Blog example
The MIT License (MIT)
Copyright (c) 2018 Gouthaman Balaraman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@gouthambs
gouthambs / blog_admin.py
Created June 20, 2017 13:27
Example of Flask-Blogging working with Flask-Admin
from flask import Flask, render_template_string, redirect
from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin, LoginManager, login_user, logout_user
from flask_blogging import SQLAStorage, BloggingEngine
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
db = SQLAlchemy()
app = Flask(__name__)
app.config["SECRET_KEY"] = "secret" # for WTF-forms and login
@gouthambs
gouthambs / gist:47c285306ccc7e27c336
Created June 17, 2015 15:08
Regular Expression Patterns
#
import re
# Identify URL
re.findall('(?:http://|www.)[^"\' ]+', html)
@gouthambs
gouthambs / linked_luigi.py
Last active August 29, 2015 14:12
Linked Luigi Example
# Linked Luigi Example - Gouthaman Balaraman
# http://gouthamanbalaraman.com/blog/building-luigi-task-pipeline.html
import luigi
class SimpleTask(luigi.Task):
"""
SimpleTask prints Hello World!.
@gouthambs
gouthambs / minimal_luigi.py
Last active August 26, 2016 23:06
Minimal Luigi Example
# Minimal Luigi Example - Gouthaman Balaraman
# http://gouthamanbalaraman.com/blog/building-luigi-task-pipeline.html
import luigi
class SimpleTask(luigi.Task):
"""
This simple task prints Hello World!
"""
@gouthambs
gouthambs / LICENSE
Last active February 17, 2020 12:12
Flask token based authentication
The MIT License
Further resources on the MIT License
Copyright 2014 Gouthaman Balaraman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@gouthambs
gouthambs / zeo_winservice.py
Last active August 29, 2015 14:04
ZEO as a service in Windows
__author__ = 'Gouthaman Balaraman'
import sys
import os
import win32event
import win32service
import win32serviceutil
import win32api
import win32con
import logging
@gouthambs
gouthambs / index.html
Created May 28, 2014 14:38
CORS Example with YQL
<!-- Serve this file, for example "python -m SimpleHTTPServer"-->
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var symbol='yhoo';
$.getJSON("http://query.yahooapis.com/v1/public/yql",
{
q : "select * from yahoo.finance.stocks where symbol='"+symbol+"'",