Skip to content

Instantly share code, notes, and snippets.

View elmontoya7's full-sized avatar
🎯
Focusing

Alexis Montoya elmontoya7

🎯
Focusing
  • Mexico City
View GitHub Profile
@elmontoya7
elmontoya7 / ssl-validator.js
Created July 23, 2019 19:06
Check certificate validity
const tls = require('tls');
const https = require('https');
const crypto = require('crypto');
function sha256(s) {
return crypto.createHash('sha256').update(s).digest('base64');
}
const options = {
hostname: 'qaenterprise.botlers.io',
port: 443,
@elmontoya7
elmontoya7 / colorFontContrast.js
Created February 10, 2018 01:42
Returns a contrasting color (black or white) depending on the background color. This is a functions used in Vue.js.
getContrastFontColor () {
if(this.colorSelected.length == 7) {
let r = parseInt(this.colorSelected.substr(1,2),16);
let g = parseInt(this.colorSelected.substr(3,2),16);
let b = parseInt(this.colorSelected.substr(5,2),16);
r *= 0.299;
g *= 0.587;
b *= 0.114;
if((r + g + b) > 186)
return '#000000';
@elmontoya7
elmontoya7 / deauthorize.js
Last active October 3, 2017 22:26
Reading a signed_request from Facebook when the user uninstalls your app.
//receive a POST request to your node.js app
router.post('/deauthorize', function (req, res) {
if(req.body.signed_request){
var app_secret = 'your_app_secret';
var data = req.body.signed_request.split('.');
if(data.length > 1){
//docs - https://developers.facebook.com/docs/games/gamesonfacebook/login#parsingsr
var signature = (new Buffer(data[0], 'base64')).toString();
var json = (new Buffer(data[1], 'base64')).toString();
@elmontoya7
elmontoya7 / usage.js
Created June 4, 2017 21:03
A6BRTGFDSFM FUNCTIONS USAGE
/**
* Created by montoya on 6/4/17.
*/
var a6Bot = new A6BotResponseTemplate(process.env.FACEBOOK_PAGE_ID);
var recipientID = 1234567890;
//SEND MESSAGE
a6Bot.message('Hello world!', recipientID);
//SEND MULTIPLE MESSAGES