Skip to content

Instantly share code, notes, and snippets.

@jbgutierrez
jbgutierrez / plot-graphviz.rb
Last active August 29, 2015 14:15
Plotting a dependency graph
#!/usr/bin/env ruby
# coding: UTF-8
require 'yaml'
ALIAS = {
text: '/vendor/requirejs-text/text',
jquery: '/vendor/jquery/dist/jquery',
dust: '/vendor/dustjs-linkedin/dist/dust-full',
dustHelpers: '/vendor/dustjs-linkedin-helpers/dist/dust-helpers',
pagejs: '/vendor/page.js/page',
@Jimbly
Jimbly / gist:2346805
Created April 9, 2012 21:54
Adding keep alive for https connections
function addKeepAliveTimeout(agent) {
function fail(msg) {
console.warn(msg + ', node version: ' + process.version);
return agent;
}
// Check it's what we expect
var old_listeners = agent.listeners('free');
if (!old_listeners || old_listeners.length !== 1) {
return fail('Unexpected lacking "free" listener');
}
@jbgutierrez
jbgutierrez / setup-continuous-deployment-ubuntu-12.10-x86_64.sh
Last active December 27, 2015 07:59
Self-contained bash script to setup continuous deployment for nodejs apps built on top of ubuntu, git and foreman
DEPLOYER='deployer'
DEPLOYER_HOME="/home/$DEPLOYER"
PROJECT_NAME='node-js-sample'
PROJECT_REPO='https://github.com/heroku/node-js-sample.git'
# Provisining an ubuntu server
apt-get -y update
apt-get -y upgrade
apt-get -y install software-properties-common
add-apt-repository ppa:chris-lea/node.js
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Backbone.js • TodoMVC</title>
<link rel="stylesheet" href="../../assets/base.css">
<!--[if IE]>
<script src="../../assets/ie.js"></script>
<![endif]-->
@vybs
vybs / rhino_dust.java
Created January 17, 2012 02:15
Sample code to rendering dust template using Rhino
package com.linkedin.dust.renderer;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;
@brittanydionigi
brittanydionigi / sw-messaging.js
Created March 16, 2015 19:41
messaging in service workers
// index.html -- Sending message TO service worker, FROM page:
navigator.serviceWorker.controller.postMessage(message);
// service-worker.js -- Handling message event in service worker by posting a message back to the page:
self.addEventListener('message', function(event) {
self.clients.matchAll().then(function(client) {
client[0].postMessage({
command: 'logMessage',
error: null,
message: 'hi there message here!!'
var express = require('express');
var app = express();
var port = process.env.PORT || 5000;
var request = require('request');
var zlib = require('zlib');
require 'rspec'
describe "Behaviour" do
it "should pass" do
true.should eq true
end
it "should fail" do
true.should eq false
end
@mmcgahan
mmcgahan / gist:9fa045d98c7c122f1c0b
Created June 18, 2014 19:09
Handlebars template inheritance
# Template composition with inclusion
Every template language I have seen provides some mechanism for one template to include another, thus supporting the reuse of repeated elements like headers and footers. The included templates are called partials in Mustache parlance:
```html
<!-- home.hbs -->
<html>
<body>
{{> header}}
<p> HOME </p>
{{> footer}}
@ryandotsmith
ryandotsmith / a-backbone-js-demo-app-sinatra-backend.md
Created January 22, 2012 01:42
Backbone demo app with sinatra backend

A Backbone.js demo app (Sinatra Backend)

Oct 16 2010

Updates

  • 04/10/2011 - Updated application.js and application.rb thanks to @rebo's comments

In this article, I will walk through some simple steps to get a [demo app][2] up and running with [Backbone.js][3] and [Sinatra][4] on [Heroku][5].