Estimated time: 10 minutes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here is my Python implementation of the hash table data structure. | |
# And here's my video where I talk about it in depth: https://youtu.be/sfWyugl4JWA | |
class Hashtable: | |
# Assumption: table_length is a prime number (for example, 5, 701, or 30011) | |
def __init__(self, table_length): | |
self.table = [None] * table_length | |
## An internal search function. | |
# If it finds the given key in the table, it will return (True, index) | |
# If not, it will return (False, the index where it would be inserted) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Loading event'); | |
var aws = require('aws-sdk'); | |
var s3 = new aws.S3({apiVersion: '2006-03-01'}); | |
var sqs = new aws.SQS({apiVersion: '2012-11-05'}); | |
exports.handler = function(event, context, callback) { | |
s3.listBuckets(function(err,data) { | |
if (err) { | |
console.log('ERROR: Problem getting list of buckets. This should have something to do with incorrect IAM permissions for the lambda.'); | |
errorMessage = 'ERROR: Error from S3: '+err; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
gather_facts: false | |
connection: local | |
become: yes | |
vars: | |
packages: | |
- apache2 | |
- mysql-server |
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
NewerOlder