Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike M. Lin mmlin

View GitHub Profile
@mmlin
mmlin / boto-mws-example.py
Created Aug 2, 2016
Amazon MWS example with boto
View boto-mws-example.py
# 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(
@mmlin
mmlin / match-bid.js
Created Feb 22, 2016
On the keywords page of an Amazon PPC campaign, match all bids – or go to the next page if all bids are already matched.
View match-bid.js
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 / gist:15e4be136a1bff3e03dc
Created Jun 23, 2015
Pardot Hack: Don't link prospects from forwarded emails!
View gist:15e4be136a1bff3e03dc
// 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 / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mmlin
mmlin / django_create_thumbnail_on_model_save.py
Created Jun 7, 2013
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.
View django_create_thumbnail_on_model_save.py
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 / gist:5732731
Created Jun 7, 2013
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.
View gist:5732731
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):
View Button CSS (Web Designer Wall)
/* 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 / easy_install and MinGW
Created Jul 1, 2011
Installing hg-git on Windows using MinGW
View easy_install and 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
You can’t perform that action at this time.