Skip to content

Instantly share code, notes, and snippets.

@nvie
nvie / sift.py
Last active December 18, 2015 15:28
The sift itertool.
from collections import deque
from functools import wraps
def inversify(predicate):
"""Returns a predicate that is the inverses of the given predicate."""
@wraps(predicate)
def _inner(*args, **kwargs):
return not predicate(*args, **kwargs)
return _inner
@balupton
balupton / README.md
Last active April 29, 2019 11:57
DocPad: Use DocPad, GitHub & Prose as a Wiki

Use DocPad, GitHub and Prose as a Wiki

This guide will walk you through how you can use a GitHub repository to house your wiki content, have DocPad render it, and automatically update on changes. It's also really nice as we get to benefit from the github project workflow for our wiki, that is issues, pull requests, etc.

We use this workflow heavily by linking the DocPad Website and the DocPad Documentation repositories allowing us to have users edit and submit pull requests for improvements to our documentation, and once merged, the website regenerates automatically.

1. Create a new repository for your Wiki Content

@shesek
shesek / gist:3929926
Created October 22, 2012 06:01
Higher order functions for nodejs-style callbacks error handling

I've used promises for quite some time, but ended up going back to nodejs-style callbacks and creating a bunch of higher-order functions that makes handling that easier and reduce the boilerplate code. The two most useful ones, that really made it much easier, deal with error handling/bubbling: (CoffeeScript)

iferr = (errfn, succfn) -> (e, a...) -> if e? then errfn e else succfn a...
throwerr = iferr.bind null, (e) -> throw e


# To let an error bubble up, `iferr` decorates the success function and the error function, and decide which one should handle the response
# This replaces `if (err) return fn err` that you see all over the place
@lwille
lwille / client_main.coffee
Created October 20, 2012 22:12
pretty clean way of obtaining reactive item counts in meteor
Meteor.autosubscribe ->
Meteor.call 'getItemCount', Session.get('currentCustomer'), (err, count)->
Session.set 'itemCount', count
@tdegrunt
tdegrunt / batmap.html
Created January 6, 2012 13:00
GoogleMapsView / Batman.View example with Batman
<!DOCTYPE html>
<html>
<head>
<title>BatMap</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="../lib/es5-shim.js"></script>
<script type="text/javascript" src="../lib/batman.js"></script>
<script type="text/javascript" src="../lib/batman.solo.js"></script>
@mklabs
mklabs / bootstrap-plugins.txt
Created December 2, 2011 11:23
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js
@cweekly-yottaa
cweekly-yottaa / GA-Perf-Data-JS.html
Created February 22, 2011 21:35
Google Analytics JavaScript enhancement: Push Web Timing Performance Data into GA custom vars
<html>
<head>
<script type="text/javascript">var yoHeadTime = new Date().getTime();</script>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
(function() {
var reportTimeSegment = function(index, name, start, end, scope) {
// jQuery.support.(displayTable|displayTableCell|margin0auto|positionFixed)
// jQuery.support.displayTable and displayTableCell -
// to determine browser support for setting elements to that css display value
$.each(['','-cell'],function(k,v){
$.support['displayTable'+v.replace('-c','C')] = (function(){
var elem = $('<div>',{
css : {
display: 'table'+v,
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@trey
trey / Appendix A of Crush It!
Created October 28, 2009 15:57
Appendix A of Crush It! by Gary Vaynerchuk
1. Identify your passion.
2. Make sure you can think of at least fifty awesome blog topics to ensure stickiness.
3. Answer the following questions:
- Am I sure my passion is what I think it is?
- Can I talk about it better than anyone else?
4. Name your personal brand. You don't have to refer to it anywhere in your content, but you should have a clear idea of what it is. For example, "The no-bs real-estate agent," "The connoisseur of cookware," "The cool guide to young-adult books boys will love to read."
5. Buy your username--.com and .tv, if possible--at GoDaddy.com.
6. Choose your medium: video, audio, written word.
7. Start a Wordpress[sic] or Tumblr account.
8. Hire a designer.