// jQuery
$(document).ready(function() {
// code
})
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.Shopping.updateMany({ | |
_id: { | |
$nin: [ | |
ObjectId("5e0002b5ee120c01b5492a3a"), | |
ObjectId("5e0001272f7790405e7c64ed"), | |
ObjectId("5e000302fbbe813c744409b3"), | |
ObjectId("5e0002c7fbbe813c744409b0"), | |
ObjectId("5e0001e02f7790405e7c64fa"), | |
ObjectId("5e0002a22f7790405e7c6505"), | |
ObjectId("5e0001ec2f7790405e7c64fd"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function orderBy($items, $attr, $order) | |
{ | |
$sortedItems = []; | |
foreach ($items as $item) { | |
$key = is_object($item) ? $item->{$attr} : $item[$attr]; | |
$sortedItems[$key] = $item; | |
} | |
if ($order === 'desc') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk') | |
const uuidBase62 = require('uuid-base62') | |
const mailcomposer = require('mailcomposer') | |
/** | |
* Upload file to AWS S3 Service | |
* @param {Buffer} f | |
* @param {String} path | |
* @param {String} filename Uploaded file's name | |
* @return {Promise<Object>} S3 Promise |