Skip to content

Instantly share code, notes, and snippets.

View gnzandrs's full-sized avatar

Gonzalo Vergara gnzandrs

View GitHub Profile
@rctay
rctay / gist:527113
Created August 16, 2010 15:18
[django] check if db table exists
"""
Came up with this for satchmo's downloadable product migration, 0001_split.
"""
def db_table_exists(table, cursor=None):
try:
if not cursor:
from django.db import connection
cursor = connection.cursor()
if not cursor:
raise Exception
@remy
remy / trim-canvas.js
Last active May 3, 2024 13:39
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,
@sourcerebels
sourcerebels / README.txt
Created November 29, 2011 13:19
Atajos de teclado para Midnight Commander
Atajos de teclado de Midnight Commander
- Trabajar con paneles.
Alt+t: Cambia entre los diferentes modos de visualización de los paneles.
Control+r: Refresca ambos paneles.
Control+u: Intercambia los dos panels.
Control+s: Busca un fichero en el panel activo.
Alt+Shift+?: Buscar archivos en .
@jmoz
jmoz / pagination.py
Created January 17, 2013 00:03
A Pagination class in Python.
class Pagination(object):
"""A Pagination object to be used for querying and displaying pagination links on frontend
Example usage:
>>> p = Pagination(total=15, per_page=5, current_page=1)
>>> p.start
0
>>> p.pages
[1, 2, 3]
@tonylukasavage
tonylukasavage / script.sh
Created May 29, 2013 18:18
Move all uncommitted changes to a new branch and revert the existing branch to HEAD. "master" has uncommitted changes. You decided you'd rather make those changes in "dev_branch". Here's how to move those uncommitted changes to "dev_branch" and then revert "master" to its last commit.
# get into the master branch
git checkout master
# create a new branch for the changes and check it out
git checkout -b dev_branch
# stash the changes until we revert master
git stash
# go back to master
@markusklems
markusklems / lambda-dynamo
Last active September 24, 2021 03:48
Short aws lambda sample program that puts an item into dynamodb
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
@veselosky
veselosky / s3gzip.py
Last active May 8, 2023 21:42
How to store and retrieve gzip-compressed objects in AWS S3
# vim: set fileencoding=utf-8 :
#
# How to store and retrieve gzip-compressed objects in AWS S3
###########################################################################
#
# Copyright 2015 Vince Veselosky and contributors
#
# 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
@medmunds
medmunds / README.md
Created March 29, 2016 02:32
Taking back your Mandrill click-tracking links

Taking back your Mandrill click-tracking links

My company, like many, has recently switched away from using Mandrill for our transactional email.

We'd been using Mandrill's [click-tracking][mandrill-click-tracking] feature, and became worried about what would happen to all those old emailed links after we cancel our Mandrill account.

Why should we care about links in emails sent a month or more ago?

@whelmed
whelmed / lamp_demo_final.yaml
Created November 7, 2016 19:08
The final result of our LAMP demo
---
- hosts: all
gather_facts: false
connection: local
become: yes
vars:
packages:
- apache2
- mysql-server