Skip to content

Instantly share code, notes, and snippets.

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

Olúwátóósìn Anímáṣahun takwas

🏠
Working from home
View GitHub Profile
@takwas
takwas / models.py
Created May 16, 2016 16:55
SQLALchemy relationship
import os
import sys
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
Base = declarative_base()
class Profile(Base):
@takwas
takwas / wsgi.py
Created May 19, 2016 13:44
Error Running a Slack bot on PythonAnywhere.com
import os, sys
#... env var configs
# add your project directory to the sys.path
project_home = u'/home/takwas/votebot'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
@takwas
takwas / dgplug.md
Last active May 25, 2016 11:37
My DgpLUG Experience

Your name (blog/twitter) and what you do.

My name is Tosin Damilare James Animashaun (IRC: acetakwas; Twitter: @acetakwas; Github: github.com/takwas, Blog: takwas.github.io).

I am currently a part-time Software Engineering student and ad-hoc faculty at NIIT, Lagos. I am also a co-founder at a startup called Krohx. We are in the final stages of deploying a job/hiring web platform that targets seekers of short-term jobs while also easing the process of getting service delivery for the hirers.

With my involvements with the burgeoning Python community in Nigeria, I recently got elected as secretary for the organization.

How did you learn about the training? (++ Your Experience)

@takwas
takwas / Traceback
Created June 27, 2016 08:09
Failed Celery demo
(flask_venv)(j) [TAK] $: celery worker -A celery_test -l info -c 3
Traceback (most recent call last):
File "/home/acetakwas/dev/my_virtualenvs/flask_venv/bin/celery", line 11, in <module>
sys.exit(main())
File "/home/acetakwas/dev/my_virtualenvs/flask_venv/local/lib/python2.7/site-packages/celery/__main__.py", line 30, in main
main()
File "/home/acetakwas/dev/my_virtualenvs/flask_venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 81, in main
cmd.execute_from_commandline(argv)
File "/home/acetakwas/dev/my_virtualenvs/flask_venv/local/lib/python2.7/site-packages/celery/bin/celery.py", line 793, in execute_from_commandline
super(CeleryCommand, self).execute_from_commandline(argv)))
# The following is the basic way to run a Flask
# app using the Flask-socketio extenstion
from flask import Flask, render_template
from flask_socketio import SocketIO
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
@takwas
takwas / bot.py
Created July 1, 2016 11:24
Logbot for DgpLUG
# standard library imports
import os
import sys
import time
import datetime
import json
import re
import logging
@takwas
takwas / __init__.py
Last active July 18, 2016 11:06
Demo: Setup a Flask application
"""
File: my_flask_app/my_flask_app/__init__.py
my_flask_app
~~~~~~~~~~~~
Flask application __init__ demo
:author: Tosin Damilare James Animashaun (acetakwas@gmail.com)
:copyright: (c) 2016
@takwas
takwas / mail_handler
Last active July 8, 2021 07:00
Flask-Mail Example
import os
from flask import Flask, render_template
from flask_mail import Mail, Message
from lepl.apps.rfc3696 import Email # $ pip install lepl
app = Flask(__name__)
app.config.update({
'MAIL_SENDER' : os.environ.get('MAIL_SENDER_EMAIL'),
@takwas
takwas / supervisor.conf
Created April 2, 2017 14:16 — forked from tsabat/supervisor.conf
Sample supervisor config file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@takwas
takwas / demo.py
Created August 14, 2017 18:23
Exception message printing demo
###########
# Python 2:
###########
try:
raise Exception
except Exception as e:
s,r = getattr(e, 'message') or str(e), getattr(e, 'message') or repr(e)
print 's:', s, 'len(s):', len(s)
print 'r:', r, 'len(r):', len(r)