Skip to content

Instantly share code, notes, and snippets.

{
"2012-04-23T00:00:00": 1310759,
"2012-04-24T00:00:00": 1160622,
"2012-04-25T00:00:00": 824838,
"2012-04-26T00:00:00": 850123,
"2012-04-27T00:00:00": 610717,
"2012-04-28T00:00:00": 471510,
"2012-04-29T00:00:00": 546146,
"2012-04-30T00:00:00": 776561,
"2012-05-01T00:00:00": 639663,
@jtdevos
jtdevos / iter_comm.py
Created April 12, 2018 18:23
comparing two sorted DBAPI rowsets in python
SOURCE_LEFT, SOURCE_RIGHT, SOURCE_BOTH = 'left', 'right', 'both'
def comm(itera, iterb, cmpfunc=None):
""" merge two iterators and indicate which items are common (similar
to the unix 'comm' command).
Return an iterator containing deduped union of two sorted iterables and
a string indicating whether merged values are unique to the 'left' iterator,
'right' iterator or if they are common to both iterators.
@jtdevos
jtdevos / how-to-set-up-stress-free-ssl-on-os-x.md
Created August 26, 2017 22:30 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@jtdevos
jtdevos / cb2str.js
Last active August 29, 2015 13:58
example of how to serialize all of the checked boxes on a form, and how to restore that state later on (requires jquery)
//return serialized list of checked checkboxes
function cb2str() {
return JSON.stringify($.map($("[id]:checkbox:checked").get(), function(el){return el.id}))
}
//check the boxes from a serialized list of checkboxes
function str2cb(str) {
$.each(JSON.parse(str), function(i, cbid){
$("#" + cbid).prop('checked', true)
});