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 / 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 / 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 />
)
}
/* SINPPET FOR DELETED & DELETED AT SUPPORT IN KNEX.JS
inspired from Sequlize.js 'paranoid' schema option,
don't delete rows from database, ever.
*/
/* In Table Definition */
knex.schema.createTable('TABLE_NAME', function(table) {
table.boolean('deleted').defaultsTo(false).notNullable();
table.dateTime('deleted_at');
@adrianolsk
adrianolsk / redirect_browser_language.nginx
Created December 1, 2017 14:25 — forked from varnav/redirect_browser_language.nginx
Nginx can redirect to language subsite based on browser language
map $http_accept_language $index_redirect_uri {
default "/en/";
"~(^|,)en.+,ru" "/en/";
"~(^|,)ru.+,en" "/ru/";
"~(^|,)en" "/en/";
"~(^|,)ru" "/ru/";
}
location = / {
return 302 $index_redirect_uri;
@adrianolsk
adrianolsk / app.js
Created March 25, 2018 15:38 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
@adrianolsk
adrianolsk / install-docker.sh
Created August 6, 2018 00:28 — forked from dweldon/install-docker.sh
Install docker CE on Linux Mint 18.3
#!/usr/bin/env bash
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
sudo apt-get install docker-ce
# https://docs.docker.com/compose/install/