Skip to content

Instantly share code, notes, and snippets.

@joepie91
joepie91 / express-server-side-rendering.md
Last active February 20, 2024 20:52
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@tmurphree
tmurphree / mongoose-cheatsheet.md
Last active April 17, 2024 18:50 — forked from subfuzion/mongoose-cheatsheet.md
mongoose cheatsheet

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');

const connectionString = process.env.MONGO_URI || 'mongodb://localhost/databasenamegoeshere';

@pbojinov
pbojinov / index.html
Last active April 8, 2018 02:32 — forked from anonymous/index.html
JS Bincheck mark success animation// source https://jsbin.com/sovase
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="check mark success animation">
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
/* animations */
@-webkit-keyframes checkmark {
@desaroxx
desaroxx / avatar.js
Last active November 18, 2023 16:54
JavaScript: create github "like" identicon avatar (result: dataurl image/png)
(function() {
// see code in action: https://jsfiddle.net/desaroxx/jp4pmd2u/
/* Configuration variables */
var MAX_COLOR = 200; // Max value for a color component
var MIN_COLOR = 120; // Min value for a color component
var FILL_CHANCE = 0.5; // Chance of a square being filled [0, 1]
var SQUARE = 80; // Size of a grid square in pixels
var GRID = 5; // Number of squares width and height
@Integralist
Integralist / flatten-array.js
Created May 20, 2015 08:35
Array flatten function written in ES6 syntax
const flattenTco = ([first, ...rest], accumulator) =>
(first === undefined)
? accumulator
: (Array.isArray(first))
? flattenTco([...first, ...rest])
: flattenTco(rest, accumulator.concat(first))
const flatten = (n) => flattenTco(n, []);
console.log(flatten([[1,[2,[[3]]]],4,[5,[[[6]]]]]))
@joyrexus
joyrexus / README.md
Last active February 19, 2024 17:15 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@pksunkara
pksunkara / config
Last active April 20, 2024 04:50
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta