Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Seldon arcseldon

View GitHub Profile
View assertions.js
//issue a token, with an expiration date
var jwt = require('jsonwebtoken')
//issue token that expires after 10 mins AND has an issuer
var token = jwt.sign('helloworld','secret',{ expiresInMinutes : 10, issuer : 'hipster.io'});
//verify token, but don't check assertions.
View configSlashtoken.js
/**
* sails-jwt-auth configuration and devdocs
*
*
*/
/**
View tokenAuth.js
var jwt = require('jsonwebtoken')
var socketjwt = require('socketio-jwt')
module.exports.issueToken = function(payload){
var token = jwt.sign(payload,sails.config.session.secret)
return token;
}
module.exports.verifyToken = function(token,verified){
@arcseldon
arcseldon / broken.txt
Created Oct 1, 2014
Sails - Broken Dependencies
View broken.txt
├── async@0.9.0
├─┬ bcrypt@0.8.0
│ ├── bindings@1.0.0
│ └── nan@1.3.0
├─┬ chai@1.9.2
│ ├── assertion-error@1.0.0
│ └─┬ deep-eql@0.1.3
│ └── type-detect@0.1.1
├── chai-as-promised@4.1.1
├── ejs@0.8.8
View gist:11569343ae2e3b6ea0bb
$ sails lift --verbose
info: Starting app...
verbose: Setting Node environment...
verbose: moduleloader hook loaded successfully.
verbose: Loading app config...
verbose: userconfig hook loaded successfully.
verbose: Exposing global variables... (you can disable this by modifying the properties in `sails.config.globals`)
verbose: logger hook loaded successfully.
View enforceSsl.js
// author arcseldon@icloud.com
'use strict';
module.exports = function (req, res, next) {
// we ARE deploying to Heroku. SSL termination happens at the load balancer,
// before encrypted traffic reaches your node app. It is possible to test
// whether https was used to make the request with req.headers['x-forwarded-proto'] === 'https'.
// See SOF answer by arcseldon: http://stackoverflow.com/a/22585754/1882064
if ((req.headers['x-forwarded-proto'] !== 'https') && (process.env.NODE_ENV === 'production')) {
return res.redirect([
@arcseldon
arcseldon / gulpfile.js
Created Dec 16, 2015 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
View gulpfile.js
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@arcseldon
arcseldon / .eslintrc.js
Created Dec 19, 2015 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
View .eslintrc.js
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@arcseldon
arcseldon / ramda
Created Jan 28, 2016 — forked from raine/ramda
Browse Ramda documentation in Terminal
View ramda
#!/usr/bin/env bash
# Browse Ramda documentation in Terminal
# Requires jq and a tool such as fzf or peco for interactive filtering
LATEST="http://raine.github.io/ramda-json-docs/latest.json"
DOCS_URL="http://ramdajs.com/docs/"
json=$(curl -s $LATEST)
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end')