Skip to content

Instantly share code, notes, and snippets.

View skyler's full-sized avatar

Skyler Slade skyler

  • Constant Contact
  • Gainesville, FL
View GitHub Profile
@dvarrazzo
dvarrazzo / prepare.py
Created September 28, 2012 01:19
An example of psycopg2 cursor supporting prepared statements
#!/usr/bin/env python
"""An example of cursor dealing with prepared statements.
A cursor can be used as a regular one, but has also a prepare() statement. If
prepare() is called, execute() and executemany() can be used without query: in
this case the parameters are passed to the prepared statement. The functions
also execute the prepared statement if the query is the same prepared before.
Prepared statements aren't automatically deallocated when the cursor is
deleted, but are when the cursor is closed. For long-running sessions creating
doc1 = {
"_id" : 1,
"p" : [ { "name" : "travis",
"age" : "21" },
{ "name" : "bob",
"age" : "21" } ] }
doc2 = {
"_id" : 2,
"p" : [ { "name" : "mark",
Dealing With Large Collections in Magento
- Collections are a good thing
- make deailing with multiple data structure types easy: Standard and EAV
- Lazy loading keep database traffic to a minimum
- Collections have some shortcomings
- When dealing with a large number of customers, getting EAV data can be difficult
The situation:
@nyov
nyov / magento-cli.py
Last active August 15, 2021 12:57
A Magento REST API example with rauth as OAuth provider. For Magento 1
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from rauth.service import OAuth1Service
# Create consumer key & secret in your Magento Admin interface
# For an API Guideline see:
# http://www.magentocommerce.com/api/rest/authentication/oauth_authentication.html
#
# Short Magento setup explanation:
mysql> CREATE TABLE autoinc1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
^[[AQuery OK, 0 rows affected (0.35 sec)
mysql> CREATE TABLE autoinc2 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
Query OK, 0 rows affected (0.17 sec)
mysql> CREATE TABLE autoinc3 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
Query OK, 0 rows affected (0.18 sec)
mysql> set @@auto_increment_offset=1;
@floer32
floer32 / centos_python_env_setup
Last active May 2, 2022 03:47 — forked from stantonk/doit
CentOS 6: Install Python 2.7.4, pip, virtualenv, and virtualenvwrapper on CentOS (plus some bonus items at the end if you want). You should probably run with `sudo`.
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
#!/usr/bin/ruby
require 'net/smtp'
FROM = "noc@example.com"
DOMAIN = "example.com"
ACCOUNT = "gmail.account@example.com"
PASSWORD = "secret"
def current_commit
#!/usr/bin/env bash
# gist at https://gist.github.com/miebach/7391024
# save this file to .git/hooks/post-checkout
# and also to .git/hooks/post-merge
# and make it executable
# Delete .pyc files and empty directories from root of project
cd ./$(git rev-parse --show-cdup)