Skip to content

Instantly share code, notes, and snippets.

@HenrikJoreteg
HenrikJoreteg / README.md
Last active September 20, 2021 01:36
Minimalist routing in Redux

Why would you want to do this? Because you often don't need more. It's nice to not have to think about your "router" as this big special thing.

Instead, with this approch, your app's current pathname is just another piece of state, just like anything else.

This also means that when doing server-side rendering of a redux app, you can just do:

var app = require('your/redux/app')
var React = require('react')
@hirobert
hirobert / response-content-disposition-cloudfront.txt
Last active December 21, 2023 20:38
response-content-disposition and cloudfront
1) Log in to aws console.
2) Click cloudfront
3) Click behaviors
4) Select pattern and edit
@raddeus
raddeus / app.js
Last active May 24, 2023 15:41
Basic Express 4.0 Setup with connect-flash
var express = require('express');
var session = require('express-session');
var cookieParser = require('cookie-parser');
var flash = require('connect-flash');
var app = express();
app.use(cookieParser('secret'));
app.use(session({cookie: { maxAge: 60000 }}));
app.use(flash());
@seanrose
seanrose / sampleBoxFileUpload.js
Last active October 28, 2022 20:16
A sample file upload in javascript to the Box API
// Requires JQuery and CORS enabled for the Origin you're testing from.
// Uncomment the next 4 lines to import JQuery
// var script= document.createElement('script');
// script.type= 'text/javascript';
// script.src= '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js';
// document.head.appendChild(script);
// Set up the multipart form using HTML5 FormData object
// https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/FormData
var form = new FormData();
@maxparm
maxparm / validate-email.js
Created April 9, 2012 17:10
JS - RFC822 Email Validation
function isEmail(email){
return /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/.test(email);
}
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}