Skip to content

Instantly share code, notes, and snippets.

View nriesco's full-sized avatar

Nico R. nriesco

  • Santiago, Chile
View GitHub Profile
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication');
const { LocalStrategy } = require('@feathersjs/authentication-local');
const { expressOauth, OAuthStrategy } = require('@feathersjs/authentication-oauth');
class GoogleStrategy extends OAuthStrategy {
// https://github.com/feathersjs/feathers/blob/be91206e3dba1e65a81412b7aa636bece3ab4aa2/packages/authentication-oauth/src/strategy.ts#L113-L119
async createEntity(profile, params) {
// check if the user exists and has access
if (youShouldLetHimIn) {
class GitHubStrategy extends OAuthStrategy {
async getProfile (authResult) {
const accessToken = authResult.access_token;
// get private email
let { data } = await axios.get('https://api.github.com/user/emails', {
headers: { authorization: `Bearer ${accessToken}` }
});
// get user data
@nriesco
nriesco / Logged.vue
Last active November 8, 2018 14:42
Detecting logged users
<template>
<div v-for="user in users" v-bind:key="item._id">
{{ user.email }}
</div>
</template>
<script>
import { mapActions } from 'vuex'
const REDIRECT_PATH = '/some/url/to/login';
@nriesco
nriesco / https-sample.js
Last active September 18, 2018 12:05
HTTPS sample
/* eslint-disable no-console */
const logger = require('./logger');
const app = require('./app');
const port = app.get('port');
// const server = app.listen(port); => moved
// added for https support
const https = require('https');
const fs = require('fs');
// ref: https://stackoverflow.com/a/37576787/2027670
async function parallelFiles () {
const files = []; // some data
await Promise.all(files.map(async (file) => {
const contents = await fs.readFile(file, 'utf8')
console.log(contents)
}));
}
// ref: https://stackoverflow.com/a/37576787/2027670
async function sequentialFiles () {
const files = []; // some data
for (let file of files) {
const contents = await fs.readFile(file, 'utf8');
console.log(contents);
}
}
# Testing with sheell
echo "Hello World"
echo "Done!"
# remember to include like this:
# [<script src="https://gist.github.com/nriesco/dd411526ffe2bc4633bb19cc1d0a3a1a.js"></script>](<script src="https://gist.github.com/nriesco/dd411526ffe2bc4633bb19cc1d0a3a1a.js"></script>)
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', { 'packages': ['gantt'] });
google.charts.setOnLoadCallback(drawChart);
function daysToMilliseconds(days) {
return days * 24 * 60 * 60 * 1000;
}
import can from 'can';
import superMap from 'can-connect/can/super-map/';
import tag from 'can-connect/can/tag/';
import 'can/map/define/define';
import feathers from './feathers'; // Import the feathers instance.
export const DisplayPurchaseOrderItems = can.Map.extend({
define: {}
});
{{#if displayPurchaseOrderItemsPromise.isPending}}
<div class="list-group-item list-group-item-info">
<h4 class="list-group-item-heading">Loading...</h4>
</div>
{{/if}}
{{#if displayPurchaseOrderItemsPromise.isRejected}}
<div class="list-group-item list-group-item-danger">
<h4 class="list-group3--item-heading">Error</h4>
</div>
{{/if}}