Skip to content

Instantly share code, notes, and snippets.

View charliezstong's full-sized avatar

Carlos Villarreal charliezstong

  • @bacatamy
  • Bogotá
View GitHub Profile
@charliezstong
charliezstong / is-private-mode.js
Created August 25, 2019 19:27 — forked from Choy-lingling/is-private-mode.js
Detect if the browser is running in Private mode (Promise based)
// uncomment if you are transpiling with Babel + Webpack
// const { window, document } = global;
/**
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise}
*
* Live demo:
* @see http://live.datatables.net/piduzelo/1
*
* This snippet uses ES2015 syntax. If you want to run it in old browsers, transpile it with Babel:
@charliezstong
charliezstong / CHANGELOG.md
Created November 21, 2018 22:51 — forked from ungoldman/CHANGELOG.md
change log template

${project-name} Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

1.0.0

  • engage
@charliezstong
charliezstong / gist:5d81c2845e2c74d4f21993edd56d1f37
Created October 23, 2018 16:30 — forked from prsws/gist:8162386
A Multi-Tenant Strategy using Yii and MySQL

Introduction

This article describes an implementation of multi-tenancy using Yii and MySQL. “Multi-tenancy” is but one (yet crucial) aspect of SaaS applications; refer to the IBM document Convert your web application to a multi-tenant SaaS solution for more information on what else makes a webapp a SaaS application.

Moreover, there are three main architectures for multi-tenant databases: separate database, separate schemas and a single database. Refer to the Microsoft document Multi-Tenant Data Architecture for more information.

As MySQL doesn’t have schemas (at least the same way MS SQL Server and Oracle do) the only choices are a separate database for each tenant and single database with “commingled” tenant data. SaaS applications with a relatively small number of tenants can be easily managed with a database for each one, but for large numbers of tenants its

@charliezstong
charliezstong / gist:337622e6c6ed8925c13b9769833b05da
Created October 6, 2018 10:51
CSS Media Queries for Desktop, Tablet, Mobile | 2018
// Stylus
fullhd()
@media all and (min-width 1480px)
{block}
widescreen()
@media all and (min-width 1280px) and (max-width 1479px)
{block}
@charliezstong
charliezstong / media-query.css
Created October 6, 2018 06:48 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@charliezstong
charliezstong / openssl_encrypt_decrypt.php
Created September 30, 2018 05:44 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@charliezstong
charliezstong / fetch-graphql.js
Created September 29, 2018 07:10 — forked from stubailo/fetch-graphql.js
Call a GraphQL API with fetch
require('isomorphic-fetch');
fetch('https://1jzxrj179.lp.gql.zone/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: '{ posts { title } }' }),
})
.then(res => res.json())
.then(res => console.log(res.data));
@charliezstong
charliezstong / Promise.all.js
Created September 29, 2018 06:30 — forked from mortegac/Promise.all.js
Resolver bien Promise.all
// Resuelve correctamente Promise.all y devuelve un arreglo de informes
Promise.all(request_promises.map(request => request
.then(r => ({ success: true, request: r }))
.catch(err => ({ success:false, error: err })
))
@charliezstong
charliezstong / async-await.js
Created September 29, 2018 06:19 — forked from mortegac/async-await.js
Ejemplo del uso de Async Await para el manejo de Promesas
const fetch = require('node-fetch')
/**********************************************************************************
OPCION TRADICIONAL
**********************************************************************************/
function getNombre(username){
const url = `https://api.github.com/users/${username}`
fetch(url)
.then( res => res.json() )
.then( json => { console.log(json.name) })
@charliezstong
charliezstong / jquery-plugin.js
Created September 26, 2018 04:11 — forked from benjasHu/jquery-plugin.js
ES6 Module jQuery Plugin Definition
import pluginify from 'pluginify';
class Plugin {
constructor() {
/* ... */
}
}
/*
Convert plugin class into a jQuery plugin