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
<?php | |
$record = array( | |
array( | |
'id' => 1, | |
'titulo' => 'Post 1', | |
'descricao' => 'Este é o meu primeiro post :D' | |
), | |
array( | |
'id' => 2, | |
'titulo' => 'Post 2', |
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
<?php | |
$token_list = array('_4as82-6assda79sasg_da7s39sa3f32ar6rta' => true,'s796as7dafsdf67d60s9s_df7das67d-796f' => false); | |
$app->hook( | |
'slim.before.router', | |
function () use ($app, $token_list) { | |
$req = $app->request(); | |
$current_path = $req->getPathInfo(); | |
if (!empty($current_path) && $current_path != '/') { | |
$access_token = $req->get('access_token'); | |
if (!isset($token_list[$access_token]) || $token_list[$access_token] !== true) { |
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( global, factory ) { | |
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | |
module.exports = factory(global); | |
} else if (typeof define === 'function' && define.amd) { | |
define([], function() { | |
return factory(global); | |
}); | |
} else { | |
global.Utilitarios = factory(global); | |
} |
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 (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | |
module.exports = Utilitarios; | |
} else if (typeof define === 'function' && define.amd) { | |
define([], function() { | |
return Utilitarios; | |
}); | |
} else { | |
window.Utilitarios = Utilitarios; | |
} |
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() { | |
var Utilitarios = (function() { | |
var Utilitarios = function(options) { | |
}; | |
Utilitarios.prototype.isNull = function(obj) { | |
return obj === null; | |
}; | |
Utilitarios.prototype.isUndefined = function(obj) { |
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
var Utilitarios = (function() { | |
var Utilitarios = function(options) { | |
}; | |
Utilitarios.prototype.isNull = function(obj) { | |
return obj === null; | |
}; | |
Utilitarios.prototype.isUndefined = function(obj) { | |
return obj === void 0; |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Minha aplicação</title> | |
<script src="utilitarios.js"></script> | |
<script> | |
var util = new Utilitarios(), | |
saldo = null; |
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
var Utilitarios = require('./utilitarios'), | |
util = new Utilitarios(), | |
saldo = null; | |
if (util.isNull(saldo)) { | |
console.log("Seu saldo é 0"); | |
} |
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
<?php | |
function converteData($format, $to_format, $date, $timezone = null) | |
{ | |
if (!empty($date)) { | |
$timezone = $timezone ? $timezone : new DateTimeZone(date_default_timezone_get()); | |
$f_date = date_create_from_format($format, $date, $timezone); | |
return date_format($f_date, $to_format); | |
} | |
return false; | |
} |
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
<?php | |
function validaData($date, $format = 'Y-m-d H:i:s') | |
{ | |
if (!empty($date) && $v_date = date_create_from_format($format, $date)) { | |
$v_date = date_format($v_date, $format); | |
return ($v_date && $v_date == $date); | |
} | |
return false; | |
} |