Skip to content

Instantly share code, notes, and snippets.

@nikmartin
nikmartin / A: Secure Sessions Howto
Last active October 30, 2024 20:13
Secure sessions with Node.js, Express.js, and NginX as an SSL Proxy
Secure sessions are easy, but not very well documented.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT]
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now.
@fdevibe
fdevibe / Users-seed-example.js
Last active November 13, 2021 15:24
Dumb, straightforward seeding Sequelize data. Feel free to improve. :-)
var _ = require('lodash'),
fs = require('fs'),
path = require('path'),
csv = require('csv'),
Sequelize = require('sequelize');
function addUser(db, filename, rolesByName, addresses) {
var parser = csv.parse({}, function (err, data) {
db.models.User.bulkCreate(
_.map(data, function (record, index) {
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@lucasbrigida
lucasbrigida / running_nightmare_headlessly_on_linux.md
Last active May 16, 2023 18:51
Running Nightmare headlessly on Linux

Installation

Installing dependencies

sudo apt-get install build-essential clang libdbus-1-dev libgtk2.0-dev \
                       libnotify-dev libgnome-keyring-dev libgconf2-dev \
                       libasound2-dev libcap-dev libcups2-dev libxtst-dev \
                       gcc-multilib g++-multilib \
                       libgtk2.0-0 libgconf-2-4 \
                       libasound2 libxtst6 libxss1 libnss3 xvfb \
@clarkdave
clarkdave / createPages.ts
Created April 15, 2018 13:11
TypeScript + Gatsby node API
import { resolve } from 'path'
import { GatsbyCreatePages } from './types'
const createPages: GatsbyCreatePages = async ({
graphql,
boundActionCreators,
}) => {
const { createPage } = boundActionCreators
const allMarkdown = await graphql(`
@chadwilken
chadwilken / Document.jsx
Created March 2, 2020 18:20
React PDF w/ UGC
import React, { useMemo } from 'react';
import {
Document as PDFDocument,
StyleSheet,
Page,
Font,
} from '@react-pdf/renderer';
import dig from 'lodash.get';
import PageFooter from './PageFooter';
import CoverPage from './CoverPage';