Skip to content

Instantly share code, notes, and snippets.

@giavac
giavac / secure_ws.js
Created February 6, 2015 17:49
Decorate the WebSocket module with an HTTPS server
var ws_cfg = {
ssl: true,
port: 8080,
ssl_key: '/path/to/ssl.key',
ssl_cert: '/path/to/ssl.crt'
};
var processRequest = function(req, res) {
console.log("Request received.")
};
@ericelliott
ericelliott / essential-javascript-links.md
Last active April 22, 2024 10:15
Essential JavaScript Links
@joeytwiddle
joeytwiddle / gist:6129676
Last active December 20, 2022 15:25
Deep population helper for mongoose
// Example usage:
// deepPopulate(blogPost, "comments comments._creator comments._creator.blogposts", {sort:{title:-1}}, callback);
// Note that the options get passed at *every* level!
// Also note that you must populate the shallower documents before the deeper ones.
function deepPopulate(doc, pathListString, options, callback) {
var listOfPathsToPopulate = pathListString.split(" ");
function doNext() {
if (listOfPathsToPopulate.length == 0) {
// Now all the things underneath the original doc should be populated. Thanks mongoose!
callback(null,doc);
@dobesv
dobesv / test.html
Created September 17, 2011 14:02
Some whitespace relating testing with jadejs
<div class="test"><!-- Adding text using | results in a newline AFTER (not before) each line-->foo
bar
baz
</div>
<div class="test"><!--I thought I could use extra | lines to insert additional whitespace but
this currently outputs | characters into the result.
-->|
foo
|
@frangio
frangio / gist:985684
Created May 22, 2011 17:22
Vim - Don't create swap files for files in the Dropbox folder (useful for folders shared with Windows people)
autocmd BufNewFile,BufRead *
\ if expand('%:~') =~ '^\~/Dropbox' |
\ set noswapfile |
\ else |
\ set swapfile |
\ endif
@MicahElliott
MicahElliott / colortrans.py
Created November 29, 2010 07:57
Convert values between RGB hex codes and xterm-256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code