Skip to content

Instantly share code, notes, and snippets.

View vcatalano's full-sized avatar

Vincent Catalano vcatalano

  • Salus Fintech
  • Tucson, AZ
View GitHub Profile
@vpicavet
vpicavet / node_edges.sql
Last active December 24, 2023 18:17
Generate a network geometry edge table in PostGIS according to a edge table and topology relations (to/from nodes) - with triggers
/*
Vincent Picavet <[email protected]>
Work distributed under MIT Licence.
Automated generation of edges geometries according to topology and nodes geometry
A nodes table and a edges table design a network.
Edges are straight lines between id_from and id_to nodes
@zlalanne
zlalanne / Python-CDATA.py
Created June 5, 2013 05:48
Adds CDATA support to Python ElementTree
import xml.etree.ElementTree as ET
def CDATA(text=None):
element = ET.Element('![CDATA[')
element.text = text
return element
ET._original_serialize_xml = ET._serialize_xml
@distantcam
distantcam / drawarc.c
Created April 28, 2013 15:30
Pebble helper functions
/*
Copyright 2013 Cameron MacFarland
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
importPackage(java.io);
(function(args) {
var templateFileExtension = 'handlebars',
output = ['// This file is auto-generated and should be ignored from version control.\n'],
console = {
log: print
},
showUsage = function() {
console.log('Usage: java -jar <rhino.jar> rhino-handlebars-compiler.js --handlebars <handlebars library path> --templates <templates directory> --output <output file>');
@HarishChaudhari
HarishChaudhari / Authorize.net important error codes.csv
Created February 1, 2013 06:17
Authorize.net important error codes in csv format
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 3 in line 1.
List of error codes to process:
response_reason_code,reason_text,reason_note
2,This transaction has been declined,
3,This transaction has been declined,
4,This transaction has been declined,The code returned from the processor indicating that the card used needs to be picked up
6,The credit card number is invalid,
7,The credit card expiration date is invalid,The format of the date submitted was incorrect
8,The credit card has expired,
13,The merchant API Login ID is invalid or the account is inactive,
19,An error occurred during processing,
from sqlalchemy import exists, text, exc, select, and_, literal, cast
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Executable, ClauseElement
class InsertFromSelect(Executable, ClauseElement):
""" Insert from select"""
def __init__(self, table, select, *fields, **kw):
self.table = table
self.select = select
@selvakn
selvakn / rhino-handlebars-precompiler.js
Created May 7, 2012 17:44
handlebars precompiler for rhino
importPackage(java.io);
(function(args) {
var templateFileExtension = 'handlebars',
output = ['// This file is auto-generated and should be ignored from version control.\n'],
console = {
log: print
},
showUsage = function() {
console.log('Usage: java -jar <rhino.jar> rhino-handlebars-compiler.js --handlebars <handlebars library path> --templates <templates directory> --output <output file>');
@obeattie
obeattie / db_utils.py
Created October 14, 2009 12:51
Exposes SQLAlchemy's sessions and transactions as context managers (so they will be managed automatically inside blocks), and also provides a transaction decorator, which wraps an entire function in a transaction
"""Utilities for managing database sessions."""
from __future__ import with_statement
import contextlib
import functools
@contextlib.contextmanager
def temp_session(session_cls, **kwargs):
"""Quick and dirty context manager that provides a temporary Session object
to the nested block. The session is always closed at the end of the block.