Skip to content

Instantly share code, notes, and snippets.

View airstrike's full-sized avatar
🎯
Focusing

Andy airstrike

🎯
Focusing
View GitHub Profile
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĂ㥹ĆćČčĎďĐđĘęĚěĹ弾ŁłŃńŇňŐőŒœŔŕŘřŚśŞşŠšŢţŤťŮůŰűŸŹźŻżŽžƒˆˇ˘˙˛˜˝–—‘’‚“”„†‡•…‰‹›€™
@airstrike
airstrike / gist:2764594
Created May 21, 2012 20:50
no gettext translation for contrib.auth models
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> settings.LANGUAGE_CODE
'pt_BR'
>>> from django.contrib.auth.models import User
>>> from django.utils.translation import ugettext as _
>>> User._meta.verbose_name
<django.utils.functional.__proxy__ object at 0x01686730>
@airstrike
airstrike / github.vim
Created May 22, 2012 18:00
Github-like color theme for vim. It's based on http://www.vim.org/scripts/script.php?script_id=2855 with fixes for .py files.
" Vim color file
"
" Author: André Terra <andreterra+nospam@gmail.com>
"
" Note: Anthony Carapetis original version of github's syntax thmee
" with a few changes, like better .py highlighting and line #s.
" Used Brian Mock's darkspectrum as a starting point/template
" Thanks to Ryan Heath for an easy list of some of the colours:
" http://rpheath.com/posts/356-github-theme-for-syntax-gem
@airstrike
airstrike / python.vim
Created May 23, 2012 14:09
unofficial python syntax file with changes too booleans, self, class, def and decorators.
" Vim syntax file
" Language: Python
" Maintainer: Neil Schemenauer <nas@python.ca>
" Last Change: 2010 Sep 21
" Credits: Zvezdan Petkovic <zpetkovic@acm.org>
" Neil Schemenauer <nas@python.ca>
" Dmitry Vasiliev
"
" This version is a major rewrite by Zvezdan Petkovic.
"
@airstrike
airstrike / reportsapi.md
Created May 28, 2012 17:02
Complex reports API draft

Draft #1

>>> from pprint import pprint
>>> a = Account.objects.get(code='M201064001')
>>> pprint(a.report(ending='2012-02', length=3))
{'M201064001': {'2011-12': {'cons': 0.12,
                            'corp': 0.88,
                            'total': Decimal('900')},
                '2012-01': {'cons': 0.12,
@airstrike
airstrike / Arrays.bas
Created August 14, 2012 14:13
VBA arrays helper module
Option Explicit
Option Compare Text
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' modArraySupport
' By Chip Pearson, chip@cpearson.com, www.cpearson.com
'
' This module contains procedures that provide information about and manipulate
' VB/VBA arrays. NOTE: These functions call one another. It is strongly suggested
' that you Import this entire module to a VBProject rather then copy/pasting
' individual procedures.
body {
font-family: "Segoe UI", Arial;
}
.qwebirc-qui .lines {
color:#d9d9d9; background-color:#313131;
border-top: 1px solid #292929;
padding:0px 5px;
}
.qwebirc-qui .outertabbar {
border-bottom: 1px solid #202020;

Python Excel Mini Cookbook

Original post at: http://pythonexcels.com/python-excel-mini-cookbook/

To get you started, I’ve illustrated a number of common tasks you can do with Python and Excel. Each program below is a self contained example, just copy it, paste it and run it. A few things to note:

These examples were tested in Excel 2007, they should work fine in earlier versions as well after changing the extension of the file within the wb.SaveAs() statement from .xlsx to .xls If you’re new to this, I recommend typing these examples by hand into IDLE, IPython or the Python interpreter, then watching the effect in Excel as you enter the commands. To make Excel visible add the line excel.Visible = True after the excel =win32.gencache.EnsureDispatch('Excel.Application') line in the script These are simple examples with no error checking. Make sure the output files doesn’t exist before running the script. If the script crashes, it may leave a copy of Excel running in the background. Open the Windows T

Const MAX_RESULTS_SIZE As Long = 100
Public Function BaseLookup(ByVal Field As String, ParamArray Lookups() As Variant) As Variant
BaseLookup = FlexLookup_( _
Caller:=Application.Caller, ShtName:="BASE", _
Field:=Field, Grouped:=True, Sorted:=True, _
RowLookup:=False, _
ProtoLookups:=Lookups)
#
# Copyright (C) 2013 Vinay Sajip. New BSD License.
#
import os
import os.path
from subprocess import Popen, PIPE
import sys
from threading import Thread
from urllib.parse import urlparse
from urllib.request import urlretrieve