Skip to content

Instantly share code, notes, and snippets.

View sketchminds's full-sized avatar

Nestor Alveyra sketchminds

  • Manila, Philippines
View GitHub Profile
@sketchminds
sketchminds / admin-validator.ts
Created September 5, 2017 04:30
Custom Validator
import { Directive, Input, Injectable } from '@angular/core';
import { FormControl, Validator, AbstractControl } from '@angular/forms';
import { Storage } from '@ionic/storage';
import * as _ from 'lodash';
@Injectable()
export class AdminValidator {
currentAdmins: any[];
@sketchminds
sketchminds / gist:e4f8965f630c5d2d02e73fc937c7e4b9
Last active June 28, 2018 16:12 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@sketchminds
sketchminds / diff
Created September 13, 2018 05:19 — forked from Alexintosh/diff
React boilerplate in subfolder
internals/webpack/webpack.base.babel.js
- publicPath: '/',
+ publicPath: '/subfolder/',
File internals/webpack/webpack.prod.babel.js
- publicPath: '/',
+ publicPath: '/subfolder/',
app/app.js
@sketchminds
sketchminds / review-checklist.md
Created October 9, 2018 04:00 — forked from bigsergey/review-checklist.md
Front-end Code Review Checklist

Review checklist

General

  1. Does the code work?
  2. Description of the project status is included.
  3. Code is easily understand.
  4. Code is written following the coding standarts/guidelines (React in our case).
  5. Code is in sync with existing code patterns/technologies.
  6. DRY. Is the same code duplicated more than twice?
@sketchminds
sketchminds / elb-nodejs-ws.md
Created July 29, 2019 10:17 — forked from obolton/elb-nodejs-ws.md
Configuring an AWS Elastic Load Balancer for a Node.js application using WebSockets on EC2

AWS ELB with Node.js and WebSockets

This assumes that:

  • You are using Nginx.
  • You want to accept incoming connections on port 80.
  • Your Node.js app is listening on port 3000.
  • You want to be able to connect to your Node.js instance directly as well as via the load balancer.

####1. Create load balancer

@sketchminds
sketchminds / _ec2-lightsail-amazon-linux-nginx-apache-proxy-php-7.md
Created August 31, 2019 22:33 — forked from irman/_ec2-lightsail-amazon-linux-nginx-apache-proxy-php-7.md
Setting up Nginx-Apache Reverse Proxy, PHP, & MariaDB with SSL on EC2/Lightsail with Amazon Linux

Setting up Nginx-Apache Reverse Proxy, PHP, & MariaDB with SSL on EC2/Lightsail with Amazon Linux

Final setup should consists of:

  1. NGINX (reverse proxy & static contents)
  2. Apache 2.4 (Dynamic content: PHP)
  3. PHP 7.1
  4. MariaDB 10.1
@sketchminds
sketchminds / LC_CTYPE.txt
Created September 1, 2019 01:06 — forked from ibrahimlawal/LC_CTYPE.txt
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@sketchminds
sketchminds / gist:4ed6c7f5d892fdaac0fb2389b332b460
Created September 19, 2019 11:23 — forked from cyakimov/gist:1139981
Decode Facebook signed_request with NodeJS
//npm install b64url
//A signed_request for testing:
//WGvK-mUKB_Utg0l8gSPvf6smzacp46977pTtcRx0puE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyOTI4MjEyMDAsImlzc3VlZF9hdCI6MTI5MjgxNDgyMCwib2F1dGhfdG9rZW4iOiIxNTI1NDk2ODQ3NzczMDJ8Mi5ZV2NxV2k2T0k0U0h4Y2JwTWJRaDdBX18uMzYwMC4xMjkyODIxMjAwLTcyMTU5OTQ3NnxQaDRmb2t6S1IyamozQWlxVldqNXp2cTBmeFEiLCJ1c2VyIjp7ImxvY2FsZSI6ImVuX0dCIiwiY291bnRyeSI6ImF1In0sInVzZXJfaWQiOiI3MjE1OTk0NzYifQ
function parse_signed_request(signed_request, secret) {
encoded_data = signed_request.split('.',2);
// decode the data
sig = encoded_data[0];
json = base64url.decode(encoded_data[1]);
data = JSON.parse(json); // ERROR Occurs Here!
@sketchminds
sketchminds / axios-catch-error.js
Created December 17, 2019 06:25 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨