Skip to content

Instantly share code, notes, and snippets.

😃
Improving leasing with code.

Fernando Dorantes fdorantesm

😃
Improving leasing with code.
Block or report user

Report or block fdorantesm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fdorantesm
fdorantesm / conekta.js
Created Aug 31, 2019
Conekta Tokenizer
View conekta.js
if (process.client) {
if (window.Conekta) {
window.Conekta.setPublicKey('key_AVyNyZZdY5AsiEEvhpm5crA')
}
}
export default class ConektaService {
static createToken (tokenParams) {
const response = new Promise((resolve, reject) => {
if (!window.Conekta.card.validateNumber(tokenParams.card.number)) {
@fdorantesm
fdorantesm / functions.php
Created Aug 26, 2019
Convert base64 to image and validation helpers
View functions.php
function base64ToImage($imageData, $path){
$data = 'data:image/png;base64,AAAFBfj42Pj4';
list($type, $imageData) = explode(';', $imageData);
list(,$extension) = explode('/',$type);
list(,$imageData) = explode(',', $imageData);
$fileName = uniqid().'.'.$extension;
$imageData = base64_decode($imageData);
file_put_contents($path."/".$fileName, $imageData);
return $fileName;
}
@fdorantesm
fdorantesm / token-generator.js
Created Jul 30, 2019 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
View token-generator.js
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@fdorantesm
fdorantesm / uploader.js
Created May 5, 2019
Cloudinary uploader
View uploader.js
import fs from 'fs'
import streamifier from 'streamifier'
import cloudinary from 'cloudinary'
cloudinary.config({
cloud_name: process.env.CLOUDINARY_NAME,
api_key: process.env.CLOUDINARY_API_KEY,
api_secret: process.env.CLOUDINARY_API_SECRET
});
@fdorantesm
fdorantesm / common.js
Last active Mar 11, 2019
Send emails using nodemailer
View common.js
import fs from 'fs'
const $app = process.env.APP_PATH
const $src = process.env.SRC_PATH
export function view(path) {
const file = `${$app}/views/${path}.pug`
if (fs.existsSync(file)) {
@fdorantesm
fdorantesm / helpers,js
Last active Oct 2, 2018
Base64 File helpers
View helpers,js
function toBytes(value){
var unit = value.substr(-2)
var size = value.replace(unit, '')
var result
switch(unit){
case 'kb': result = size * 1000; break;
case 'mb': result = size * 1000000; break;
case 'gb': result = size * 1000000000; break;
case 'tb': result = size * 1000000000000; break;
@fdorantesm
fdorantesm / README.md
Created Jun 13, 2018 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods
View README.md

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@fdorantesm
fdorantesm / form-shortcut-submit.js
Created Jun 4, 2018
Submit forms with ctrl/cmd + enter
View form-shortcut-submit.js
window.addEventListener('load', function(){
forms = document.getElementsByTagName('form')
for (form of forms) {
form.addEventListener('keydown', function(e) {
if (e.keyCode == 13 && e.metaKey) {
$button = form.querySelector('button[type="submit"]')
$button.click()
return false
}
})
@fdorantesm
fdorantesm / media.sass
Last active Apr 22, 2018
Media query sass mixin helper
View media.sass
$screen-xs-max: 480px
$screen-sm-min: 481px
$screen-sm-max: 960px
$screen-md-min: 961px
$screen-md-max: 1280px
$screen-lg-min: 1281px
@mixin xs($max-width: true)
@if $max-width
@media only screen and (max-width: $screen-xs-max)
@fdorantesm
fdorantesm / flexbox.css
Last active Apr 22, 2018
Grid generator sass mixin
View flexbox.css
.col {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
-ms-flex-preferred-size: 0;
flex-basis: 0;
max-width: 100%;
}
.start-xs {
You can’t perform that action at this time.