Skip to content

Instantly share code, notes, and snippets.

View blogui91's full-sized avatar
🎯
Focusing

Cesar Santana blogui91

🎯
Focusing
  • Doorvel
  • Monterrey
  • 17:00 (UTC -06:00)
View GitHub Profile
import Service from 'easy-requests'
export class Client extends Service {
constructor() {
super();
}
static deactivate() {
let ClientService = new Client();
import Service from 'easy-requests'
class Client extends Service
{
constructor(){
super();
this.config.endpoint = 'my-clients'
//this.config.origin = 'https://myapi.com'
//this.config.prefix = 'admin'
}
}
import Service from 'easy-requests'
class Client extends Service
{
constructor(){
super();
}
}
import routes from 'routes'
import Axios from 'axios'
export const Client = {
find(client_id) {
var client_promise = new Promise((resolve, reject) => {
axios.get(routes.RESOURCE_URL + client_id, (data) => {
resolve(data);
})
.catch((err) => {
@blogui91
blogui91 / javascript aspect ratio calculation (with GCD)
Created May 17, 2017 17:30 — forked from phobeo/javascript aspect ratio calculation (with GCD)
javascript aspect ratio calculation algorithm (take the GCD and divide both elements of resolution)
/* euclidean GCD (feel free to use any other) */
function gcd(a,b) {if(b>a) {temp = a; a = b; b = temp} while(b!=0) {m=a%b; a=b; b=m;} return a;}
/* ratio is to get the gcd and divide each component by the gcd, then return a string with the typical colon-separated value */
function ratio(x,y) {c=gcd(x,y); return ""+(x/c)+":"+(y/c)}
/* eg:
> ratio(320,240)
"4:3"
> ratio(360,240)
/*
var Trait1 = {
method1() {}
};
var Trait2 = {
method2() {}
};
var Trait3 = mixin({
Instrucciones:
1. El nombre de la clase tiene que ser en Singular y en Pascal case. Esto debido a que el nombre de la ruta va a depender de este
por ejemplo, si la clase se llama MySuperLargeUrl entonces nuestra ruta será http://nombredelaapi.com/prefijo/my-syper-large-url
2. Puedes cambiar el prefijo (por ej. '/admin/endpointname'), endpoint (por ej. 'prefix/users/') y el origen (por ej. www.api.myapp.com/prefix/endpoint)
Para hacer un poco entendible, veamos este ejemplo
...
class MySuperService extends Service
constructor() {
@blogui91
blogui91 / 01_Laravel 5 Simple ACL manager_Readme.md
Created December 7, 2016 04:19 — forked from amochohan/01_Laravel 5 Simple ACL manager_Readme.md
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

@blogui91
blogui91 / json-to-csv.php
Created November 9, 2016 06:59 — forked from Kostanos/json-to-csv.php
Convert JSON array file to CSV. Use the array keys as the first row. Command line using: json-to-csv.php json.filename > csv.filename
#!/usr/bin/php
<?php
/*
* Convert JSON file to CSV and output it.
*
* JSON should be an array of objects, dictionaries with simple data structure
* and the same keys in each object.
* The order of keys it took from the first element.
*
* Example:
@blogui91
blogui91 / Materialize CSS - Modal Fixed Header
Created November 8, 2016 20:06 — forked from nate-strauser/Materialize CSS - Modal Fixed Header
How to have a fixed modal header with materializecss
Modal Markup:
<div class="modal modal-fixed-header">
<div class="modal-header">
HEADER CONTENT
</div>
<div class="modal-content">
MAIN CONTENT
</div>
</div>