Skip to content

Instantly share code, notes, and snippets.

View adrianolsk's full-sized avatar

Adriano Skroch adrianolsk

  • Wealthsimple
  • Calgary, Canada
View GitHub Profile
/*
* Javascript makeslug()
* by J. Santos <jefrey[at]jefrey[dot]ml>
*/
/*
Usage:
string makeslug( string val [, string replaceBy = "-" ] )
Example:
@adrianolsk
adrianolsk / download-image.js
Created March 9, 2016 19:10
Image url to base64
//https://atmospherejs.com/froatsnook/request
Meteor.methods({
downloadImage: function (imageUrl) {
//https://atmospherejs.com/froatsnook/request
var result = request.getSync(imageUrl, {encoding: null});
return 'data:image/png;base64,' + new Buffer(result.body).toString('base64');
}
})
@adrianolsk
adrianolsk / Docker commands
Last active November 29, 2017 15:53
Ubuntu Server snippets
docker run -d --name web nginx:alpine
Then update the restart-policy;
docker update --restart=always web
docker run -d --name [container] --restart=always -p 8081:8080 [imagename]
@adrianolsk
adrianolsk / stopwords.txt
Created August 26, 2016 21:04 — forked from alopes/stopwords.txt
Portuguese stop words
de
a
o
que
e
do
da
em
um
para
@adrianolsk
adrianolsk / Firebase Database API Cheatsheet
Created April 28, 2017 17:35 — forked from odigity/Firebase Database API Cheatsheet
Firebase Database API Cheatsheet
There is no way to store an empty object/array/null value.
There are also no actual arrays. Array values get stored as objects with integer keys.
(If all keys are integers, it will be returned as an array.)
Basically, it's one giant tree of hashes with string keys.
Simply write a value to any location, and the intermediary locations will automatically come into existance.
── Classes ──
DataSnapshot : Container for a subtree of data at a particular location.
'use strict';
module.exports = function(app) {
return function(req, res, next) {
app.service('things').Model.aggregate([{
$match: {}
}, {
$project: {
year: {
$year: '$createdAt'
@adrianolsk
adrianolsk / query
Created May 30, 2017 17:09
Feathers Query - Mongo
// search with regex
query = { fieldName: { $regex: 'pattern', $options: 'igm' } }
@adrianolsk
adrianolsk / Dockerfile
Created August 1, 2017 14:18
Docker file that install node using nvm
FROM node:argon
RUN apt-get update
RUN apt-get install -y less
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
ENV SHIPPABLE_NODE_VERSION=v4.2.2
RUN . $HOME/.nvm/nvm.sh && nvm install $SHIPPABLE_NODE_VERSION && nvm alias default $SHIPPABLE_NODE_VERSION && nvm use default && npm install gulp babel jasmine mocha serial-jasmine serial-mocha aws-test-worker -g
@adrianolsk
adrianolsk / authentication.js
Created August 14, 2017 16:31 — forked from marshallswain/authentication.js
Example tools for using querystring redirects with Feathers OAuth login.
'use strict';
const authentication = require('feathers-authentication');
const jwt = require('feathers-authentication-jwt');
const local = require('feathers-authentication-local');
const oauth2 = require('feathers-authentication-oauth2');
const GithubStrategy = require('passport-github');
// Bring in the oauth-handler
const makeHandler = require('./oauth-handler');
@adrianolsk
adrianolsk / gist:c0136f483e7c7ac150fc310b01ccb7b8
Last active August 17, 2017 13:34 — forked from Maruz/gist:9274096e436f83e59524bdd09b6cc030
React conditional component rendering
<nav className='navbar'>
{
userRole === 'admin' && (
<AdminPanel />
) || userRole === 'user' && (
<UserPanel />
) || (
<StatusPanel />
)
}