Skip to content

Instantly share code, notes, and snippets.

View blogui91's full-sized avatar
🎯
Focusing

Cesar Santana blogui91

🎯
Focusing
  • Doorvel
  • Monterrey
  • 12:11 (UTC -06:00)
View GitHub Profile
function readDir(start, callback) {
// Use lstat to resolve symlink if we are passed a symlink
fs.lstat(start, function(err, stat) {
if(err) {
return callback(err);
}
var found = {dirs: [], files: []},
total = 0,
processed = 0;
function isDir(abspath) {
/*http://i-skool.co.uk/mobile-development/web-design-for-mobiles-and-tablets-viewport-sizes/*/
/*At least requires the meta viewport tag with content 'width=device-width'*/
@media only screen and (max-width: 1080px) and (orientation : portrait) {
/* PORTRAIT:
Windows Surface Pro*/
}
@media only screen and (max-width: 800px) and (orientation : portrait) {
/* PORTRAIT:
Acer Iconia Tab A100
var required_fields = ['place','start_date','end_date','description'];
var message_errors = {
place : 'Place is required',
start_date : 'start_date required',
end_date : 'end_date is required',
description : 'description is required',
invalid_dates : 'Start date has to be less than end date'
};
@blogui91
blogui91 / README
Created June 16, 2016 03:07 — forked from adilapapaya/README
Export Table Data to CSV using Javascript
Example code for exporting data in a table to a csv file.
@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>
@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 / 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

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() {
/*
var Trait1 = {
method1() {}
};
var Trait2 = {
method2() {}
};
var Trait3 = mixin({
@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)