Goal: Connect to MSSQL using FreeTDS / ODBC in Python.
Host: Ubuntu 11.10 x86_64
Install:
sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy
In /etc/odbcinst.ini:
| # NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776 | |
| $ cd /usr/src | |
| $ wget http://nginx.org/download/nginx-1.2.1.tar.gz | |
| $ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz | |
| $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
| $ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
| $ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz |
| """SQLAlchemy Metadata and Session object""" | |
| from sqlalchemy import MetaData, types | |
| from sqlalchemy.orm import scoped_session, sessionmaker | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from datetime import datetime, date | |
| __all__ = ['Session', 'metadata', 'BaseModel'] | |
| Session = scoped_session(sessionmaker(expire_on_commit=False)) |
| /* Kosso : March 12th 2011 | |
| This the only way I managed to do this without the app crashing on resume. | |
| Done slightly differently to the KS example, since they unregister the service and | |
| do not use a setInterval timer. | |
| */ | |
| //############ in app.js : | |
| // test for iOS 4+ |
| <project name="{{ name }}" default="help" basedir="."> | |
| <property name="username" value="{{ username }}"/> | |
| <property name="host" value="{{ host }}"/> | |
| <property name="dir" value="/srv/{{ path }}/"/> | |
| <tstamp> | |
| <format property="TODAY_UK" pattern="yyyyMMddhhmmss" locale="en,UK"/> | |
| </tstamp> |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # Example of Singleton design pattern | |
| # Copyright (C) 2011 Radek Pazdera | |
| # This program is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation, either version 3 of the License, or | |
| # (at your option) any later version. |
Goal: Connect to MSSQL using FreeTDS / ODBC in Python.
Host: Ubuntu 11.10 x86_64
Install:
sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy
In /etc/odbcinst.ini:
| import itertools | |
| import requests, lxml, lxml.html | |
| import json | |
| # 7603 Hard Drives | |
| # 7611 RAM | |
| # 6642 random store | |
| def newegg_stores_req(): | |
| r = requests.api.get('http://www.ows.newegg.com/Stores.egg/Menus') | |
| return [store['StoreID'] for store in json.loads(r.content)] |
| ; 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 |
| class ApplicationController < ActionController::Base | |
| # ... | |
| unless Rails.application.config.consider_all_requests_local | |
| rescue_from Exception, with: lambda { |exception| render_error 500, exception } | |
| rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } | |
| end | |
| private | |
| def render_error(status, exception) |
Place me.mailcatcher.plist into ~/Library/LaunchAgents, then run launchctl load ~/Library/LaunchAgents/me.mailcatcher.plist.
If you use pow, echo 1080 > ~/.pow/mailcatcher and go to http://mailcatcher.dev, otherwise use http://localhost:1080.
Currently pow doesn't seem to pass websockets through correctly. Looking into this.