Skip to content

Instantly share code, notes, and snippets.

@mmlin
mmlin / easy_install and MinGW
Created July 1, 2011 19:57
Installing hg-git on Windows using MinGW
Here's how I installed hg-git on Windows using the MinGW compiler.
PREPARE
-------
- Install Python (http://www.activestate.com/activepython/downloads)
- Install the Python package manager, setuptools (http://pypi.python.org/pypi/setuptools)
- Install the MinGW installer (http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get/)
- Install the C compiler, MinGW gcc, and a utility, pexports, to help create the import library
/* button
http://webdesignerwall.com/tutorials/css3-gradient-buttons
---------------------------------------------- */
.button {
display: inline-block;
zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
*display: inline;
vertical-align: baseline;
margin: 0 2px;
outline: none;
@mmlin
mmlin / gist:5732731
Created June 7, 2013 22:03
Django - Create thumbnail on model save. Creates a thumbnail when saving a model by cropping it to square and resizing to 280x280. The thumbnail is not created if the original image is smaller than 280x280, doesn't exist, or if a thumbnail already exists.
from cStringIO import StringIO
from django.core.files.base import ContentFile
from django.db import models
from PIL import Image
 
class SomeModel(models.Model):
image = models.ImageField(upload_to='images', blank=True)
thumbnail = models.ImageField(upload_to='thumbnails', blank=True)
 
def create_thumbnail(self):
@mmlin
mmlin / django_create_thumbnail_on_model_save.py
Created June 7, 2013 22:05
Django – Create thumbnail on model save. Creates a thumbnail when saving a model by cropping it to square and resizing to 280x280. The thumbnail is not created if the original image is smaller than 280x280, doesn't exist, or if a thumbnail already exists.
from cStringIO import StringIO
from django.core.files.base import ContentFile
from django.db import models
from PIL import Image
 
class SomeModel(models.Model):
image = models.ImageField(upload_to='images', blank=True)
thumbnail = models.ImageField(upload_to='thumbnails', blank=True)
 
def create_thumbnail(self):
@mmlin
mmlin / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mmlin
mmlin / gist:15e4be136a1bff3e03dc
Created June 23, 2015 04:34
Pardot Hack: Don't link prospects from forwarded emails!
// Forgets the current user (similar to clearing cookies)
// if he changes the email address.
//
// Requires jQuery and the "Not You" setting on the Pardot form.
//
$(function() {
var $email, $notYou, href;
// Get the email section from the Pardot form.
@mmlin
mmlin / match-bid.js
Created February 22, 2016 19:12
On the keywords page of an Amazon PPC campaign, match all bids – or go to the next page if all bids are already matched.
document.body.style.background = '#fff';
var links = $('a:contains("match bid")');
if (links.length) {
links.click();
} else {
var next = $('.a-last a');
if (next.length) {
next.click();
} else {
document.body.style.background = '#fee'
@mmlin
mmlin / boto-mws-example.py
Created August 2, 2016 06:37
Amazon MWS example with boto
# MWS API docs at http://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Datatypes.html#Order
# MWS Scratchpad at https://mws.amazonservices.com/scratchpad/index.html
# Boto docs at http://docs.pythonboto.org/en/latest/ref/mws.html?#module-boto.mws
from boto.mws.connection import MWSConnection
...
# Provide your credentials.
conn = MWSConnection(