Skip to content

Instantly share code, notes, and snippets.

View parkerproject's full-sized avatar

Parker parkerproject

View GitHub Profile

Authors Guide: Article Template

Please submit your article including all of the information below. You can include this as a seperate file if you like - but please complete each section. Please use an online service to write your article, for example Dropbox Paper, Draft.in, Google Docs. For more help, see the editorial guide

Article Title

Ideally under 67 characters, what problem does this article solve?

Quick Summary

@parkerproject
parkerproject / gist:67b0c9e7b52366cef18cc6e1012ef009
Created January 14, 2021 03:27 — forked from sangkyoonnam/gist:9128870
Node.js Hello World with Express.js
/**
* Module Dependencies
*/
var express = require('express');
var app = express();
/**
* Configuration
*/
@parkerproject
parkerproject / directUploadToS3.js
Created December 26, 2020 01:04 — forked from DWboutin/directUploadToS3.js
Direct image url to S3 wiht axios and nodejs
import AWS from 'aws-sdk';
import stream from 'stream'
import axios from 'axios';
export default async (url, filename, callback) => {
const s3 = new AWS.S3({ params: { Bucket: process.env.STATIC_MAPS_BUCKET }});
let contentType = 'application/octet-stream'
let promise = null
const uploadStream = () => {
@parkerproject
parkerproject / fileUploadsWithBusboy.js
Created December 24, 2020 20:00 — forked from rhamedy/fileUploadsWithBusboy.js
Upload files with busboy module nodejs and expressjs
//you do not necessary need all of the following, i copy/pasted a piece from
//one of my projects.
var express = require('express');
var fs = require('fs');
var Busboy = require('busboy');
var mime = require('mime');
var https = require('https');
var querystring = require('querystring');
var router = express.Router();
@parkerproject
parkerproject / README.md
Created November 11, 2020 04:40 — forked from atufkas/README.md
rss feed generation from mongojs result using node, express and node-rss

Situation

For my tiny blog (engine) based on node, express/connect and mongojs I needed a simple rss feed solution. I discovered and decided to go with the nice working npm module node-rss instead of writing xml myself.

What this code example does

Basically I create an get event on route /feed/rss, generate a node-rss object initialized with base values and add item elements to it while looping over a mongojs collection result array (holding my post items to be reflected). Finally I send a response with an appropriate content type header. My example is directly bound to an express get event callback for a simple static request path, but you may of course move it to route exports or whatever.

Notes

No big deal, but you might find this portion of code useful as a starting point when seeking for rss solutions.

1/2/2017
moment().format("M/D/YYYY");
01/02/2017
moment().format("MM/DD/YYYY");
14:57:22
moment().format("HH:mm:ss");
02:57 PM
@parkerproject
parkerproject / Page.js
Created September 5, 2020 02:03 — forked from PastorBones/Page.js
NodeJS & Express easy page builder
var Page = function(opt){
var self = this
self.global = {
styles: []
, scripts: []
, keywords: []
}
@parkerproject
parkerproject / downloadString.js
Created June 29, 2020 03:22 — forked from danallison/downloadString.js
download string as text file
function downloadString(text, fileType, fileName) {
var blob = new Blob([text], { type: fileType });
var a = document.createElement('a');
a.download = fileName;
a.href = URL.createObjectURL(blob);
a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
a.style.display = "none";
document.body.appendChild(a);
a.click();
@parkerproject
parkerproject / getTitleNative.js
Created May 4, 2020 13:25 — forked from jbinto/getTitleNative.js
Get title from remote HTML URL - without jQuery
// Only using native browser features (no jQuery).
// Uses `fetch`, `DOMParser` and `querySelectorAll`.
const getTitle = (url) => {
return fetch(`https://crossorigin.me/${url}`)
.then((response) => response.text())
.then((html) => {
const doc = new DOMParser().parseFromString(html, "text/html");
const title = doc.querySelectorAll('title')[0];
return title.innerText;
@parkerproject
parkerproject / start.js
Created March 23, 2020 22:31 — forked from kellyrmilligan/start.js
start.js - adjusted
'use strict';
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {