Skip to content

Instantly share code, notes, and snippets.

View ryanlelek's full-sized avatar
🔮
Like Magic

Ryan Lelek ryanlelek

🔮
Like Magic
View GitHub Profile
@ryanlelek
ryanlelek / Node SSL
Last active December 28, 2015 18:19
Node.js Express SSL
This Gist will help you configure SSL on a pure Node.js server
(without a server like Apache/nginx, but you should probably use it in production!)
# First, run your node script with nohup
# (keep the "&" at the end, it puts the process in teh background)
nohup node server/index.js --port 8443 &
# Now we capture the process ID so we know what to kill later
export SERVER_PID=$!;
echo $SERVER_PID;
# Sleep 5 Seconds to allow the server script time to startup
@ryanlelek
ryanlelek / api_nock_text.js
Last active December 31, 2015 03:08
Node.js API Testing with Nock
'use strict';
// Modules
var request = require('request');
var nock = require('nock');
// API You want to use/mock/test
var api_url = 'http://api.example.com';
// You can put this into a separate .json file and just require() it
#!/bin/bash
# http://forums.powervps.com/showthread.php?t=1313
# f = background
ssh -Ngf -L 12345:127.0.0.1:3306 [email protected]
'use strict';
// Firstly, please don't use this in production.
// Use nginx forwarding/upstream instead
// Nginx is way more secure and battle-tested
// ################
// ### Method 1 ###
// ################
'use strict';
// I'd strongly recommend not using Socket.io rooms
// This will make it more difficult to switch to another
// WebSocket library that may not support rooms (SockJS?)
// You can use Redis or another data store to create rooms and add/remove users
// But, here it is for historical and educational purposes
// Socket.IO v0.7 now gives you one Socket per namespace you define:
'use strict';
// Modules
var request = require('request');
// Variables
var settings = {
host : 'http://localhost:8443',
version : 'v0',
verifySSL : false,
@ryanlelek
ryanlelek / SublimeSettings.json
Last active August 29, 2015 14:01
Sublime Settings
{
"auto_complete": false,
"auto_match_enabled": false,
"color_scheme": "Packages/Color Scheme - Default/Blackboard.tmTheme",
"draw_white_space": "all",
"font_size": 21,
"highlight_modified_tabs": true,
"line_numbers": true,
"open_files_in_new_window": false,
"preview_on_click": false,
@ryanlelek
ryanlelek / install.sh
Last active August 29, 2015 14:05
JSON Print Script
curl -o /usr/local/bin/prettyjson https://gist.githubusercontent.com/ryanlelek/78fc643886628e454a56/raw/12380b8ab13b9c23e1c34c9fe996c01e40b2eccb/prettyjson.py; chmod +x /usr/local/bin/prettyjson;
@ryanlelek
ryanlelek / bootstrap_centered.html
Created August 28, 2014 06:11
Bootstrap Centered Jumbotron
<!DOCTYPE html>
<html>
<head>
<!-- Credit: http://stackoverflow.com/questions/22196587/how-to-center-align-vertically-the-container-in-bootstrap -->
<title>Bootstrap Centered Jumbotron</title>
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css" />
<style type="text/css">