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:
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:
# Discussing Flask templating with Hazel|work on #pocoo. | |
# Mixing request args and view func args in a template. | |
# Re: http://pastebin.com/Jr8ZUb25 | |
from flask import Flask, request, render_template | |
app = Flask(__name__) | |
"Customize Flask to select a template based on some criteria." | |
import os | |
from flask import Flask, request, render_template | |
from flask.helpers import locked_cached_property | |
from jinja2 import FileSystemLoader, TemplateNotFound | |
# Import a detection utility from your project, not defined here. | |
# Takes a request object and returns True if browser is mobile. |
#!/bin/bash | |
# Produce CSV of each installed package and full copyright of each package. (Debian) | |
# | |
# Sample CSV: | |
# Package,Version,Section,Homepage,Source | |
# bash,4.1-2ubuntu3,shells,http://tiswww.case.edu/php/chet/bash/bashtop.html, | |
# git-core,1:1.7.0.4-1ubuntu0.2,vcs,, | |
# python,2.6.5-0ubuntu1,python,,python-defaults | |
AUDIT_DIR="${HOSTNAME}-package-audit/`date +'%Y-%m-%d'`" |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
if (convertView == null) { | |
convertView = activity.getLayoutInflater().inflate(layoutId, null); | |
convertView.setTag(convertView.findViewById(textViewId)); | |
} | |
TextView textView = (TextView) convertView.getTag(); | |
textView.setText(items.get(position).getTitle()); | |
return convertView; | |
} |
"Convert dp dimensions to px dimensions, rewriting .xml files in place." | |
# Rewrite all .xml files in res/ with: | |
# find res -name '*.xml' | xargs python dp2px.py | |
import decimal | |
import re | |
import sys | |
# scale = getResources().getDisplayMetrics().density; // In Activity. |
"Web application config which picks values based on deployment/hostname." | |
# Ron DuPlain <ron.duplain@gmail.com> | |
# Developed by Ron DuPlain and Dan Lepage for Private Practice LLC. | |
# | |
# This listing serves as an example, extracted from a real-world config.py. | |
# The resulting config picks values based on hostname, which can be overriden | |
# by the DEPLOYMENT environment variable. Add to each .wsgi as appropriate: | |
# | |
# import os |
"Plot a PNG using matplotlib in a web request, using Flask." | |
# Install dependencies, preferably in a virtualenv: | |
# | |
# pip install flask matplotlib | |
# | |
# Run the development server: | |
# | |
# python app.py | |
# |
You have a Linux box. It has RAM. You'd like to log and monitor memory usage. You have many options -- here's one: use a check_mem plugin for Nagios, but use it stand-alone at first. You'll have detailed memory logging in just a minute, and will take your first step toward full system monitoring with Nagios (later when you can formally install the plugin).
Download: https://raw.github.com/justintime/nagios-plugins/master/check_mem/check_mem.pl
Read it and make sure you feel comfortable running it. Then chmod a+x check_mem.pl
and see help with ./check_mem.pl -h
. In one shell, run it in a 5s loop, logging to /tmp/mem.log (Control-C to stop):