Skip to content

Instantly share code, notes, and snippets.

View philkeys's full-sized avatar

Phil Keys philkeys

View GitHub Profile
@philkeys
philkeys / SassMeister-input-HTML.html
Created October 16, 2014 04:59
Generated by SassMeister.com.
<div class="thing"></div>
<h2>Standard</h2>
<div class="icr-main-info-glyphs">
<div class="media-content">
<h3>Media Content Header</h3>
<p>Media Content Body</p>
</div>
</div>
@philkeys
philkeys / SassMeister-input-HTML.html
Created October 25, 2014 02:45
Generated by SassMeister.com.
<!-- <h2>Standard</h2>
<div class="icr-main-info-glyphs">
<div class="media-content">
<h3>Media Content Header</h3>
<p>Media Content Body</p>
</div>
</div>
<h2>Standard - flipped</h2>
<div class="icr-main-info-glyphs-1">
@philkeys
philkeys / SassMeister-input-HTML.html
Created November 19, 2014 05:19
Generated by SassMeister.com.
<div class="block"></div>
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@philkeys
philkeys / rendering.js
Last active August 29, 2015 14:26
WebDev with Node and Express => Rendering content with Express
// basic usage
app.get('/about', function (req, res) {
res.render('about');
});
// response codes other than 200
app.get('/error', function (req, res) {
res.status(500);
res.render('error');
});
@philkeys
philkeys / process-forms-express.js
Created July 29, 2015 02:36
WebDev with Node and Express => Processing forms using Express and Node
// basic form processing
// body-parser middleware must be linked in!
app.post('/process-contact', function (req, res) {
console.log('Received contact from ' + req.body.name + ' <' + req.body.email + '>');
// save to the database
// redirect to a thank you view and send the correct status code
res.redirect(303, '/thank-you');
});
// more reobust processing
@philkeys
philkeys / providing-an-api.js
Last active August 29, 2015 14:26
WebDev with Node and Express => Providing an API
// When providing an API, the parameters will most likely be in req.query,
// though you can use req.body. You'll usually return JSON, XML, or plaintext
// and you'll often be using less common HTTP methods like PUT, POST, and DELETE.
////////////////
// GET Endpoint
////////////////
var tours = [
{ id: 0, name: 'Hood River', price: 99.99 },
@philkeys
philkeys / WDNE-handlebar-basics.handlebars
Last active August 29, 2015 14:26
Web Dev with Node and Express => Handlebar Basics
{
currency: {
name: 'United States dollars',
abbrev: 'USD'
},
tours: [
{ name: 'Hood River', price: '$99.95' },
{ name: 'Oregon Coast', price: '$159.99' }
],
specialsUrl: '/january-specials',
@philkeys
philkeys / WDNE-handlebar-express-include.handlebars
Created July 29, 2015 03:50
Web Dev with Node and Express => Handlebar Basics - Including into an Express Project
// npm install --save express-handlebars
var handlebars = require('express-handlebars')
.create({ defaultLayout: 'main' });
app.engine('handlebars', handlebars.engine);
app.set('view engine', 'handlebars');
@philkeys
philkeys / WDNE-layouts.js
Created July 29, 2015 04:16
Web Dev with Node and Express => Layouts
// setting up the standard layout
var handlebars = require('express-handlebars')
.create({defaultLayout: 'main' });
// To use the default layout with a view
app.get('/foo', function(req, res) {
res.render('foo');
});