Skip to content

Instantly share code, notes, and snippets.

View arcseldon's full-sized avatar

Richard Seldon arcseldon

View GitHub Profile
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){
//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.
/**
* sails-jwt-auth configuration and devdocs
*
*
*/
/**
$ 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.
@arcseldon
arcseldon / broken.txt
Created October 1, 2014 07:27
Sails - Broken Dependencies
├── 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
// 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 December 16, 2015 12:53 — forked from danharper/gulpfile.js
New ES6 project with Babel, Browserify & Gulp
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 December 19, 2015 10:17 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@arcseldon
arcseldon / ramda
Created January 28, 2016 17:50 — forked from raine/ramda
Browse Ramda documentation in Terminal
#!/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')
@arcseldon
arcseldon / ramdadocs.jpg
Last active February 19, 2016 16:32
Ramda search
Test