Skip to content

Instantly share code, notes, and snippets.

def explain!
puts 'Want to embed this Gist?'
puts 'Use this: <script src="http://gist.github.com/2059.js"></script>'
end
explain!
// HTTP client for testing high connection concurrency
// Authors: Richard Jones and Rasmus Andersson
// Released in the public domain. No restrictions, no support.
#include <sys/types.h>
#include <sys/time.h>
#include <sys/queue.h>
#include <stdlib.h>
#include <err.h>
#include <event.h>
#include <evhttp.h>
@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.
@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();
// 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,
@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) {
@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
@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>
@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
@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