Skip to content

Instantly share code, notes, and snippets.

View RodolfoSilva's full-sized avatar
🏠
Working from home

Rodolfo Silva RodolfoSilva

🏠
Working from home
View GitHub Profile
@RodolfoSilva
RodolfoSilva / utilitarios.js
Created May 7, 2014 11:26
Utilitarios.js Modular AMD, Node.js, Browser
(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);
}
@RodolfoSilva
RodolfoSilva / Hoks.php
Created June 5, 2014 10:14
HOOKS Validação de token
<?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) {
@RodolfoSilva
RodolfoSilva / gist:71e348cf2fe62ea0456b
Created June 6, 2014 11:56
Simulando resultado do banco de dados utilizando uma matriz
<?php
$record = array(
array(
'id' => 1,
'titulo' => 'Post 1',
'descricao' => 'Este é o meu primeiro post :D'
),
array(
'id' => 2,
'titulo' => 'Post 2',
@RodolfoSilva
RodolfoSilva / Model.php
Created June 6, 2014 12:54
Cria uma class para geração dinâmica dos métodos
<?php
class Model
{
/* armazena os dados retornado do banco de dados */
private $data;
/* construtor */
public function __construct($data)
{
$this->data = $data;
{#
time can be any string acceptable by http://www.php.net/strtotime, the
template will output that time's month.
If you don't want to pass in a date you can set time like this:
{% set time = "now"|date("U") %}
{% set time = "December 2012"|date("U") %}
How ever you want to output items onto the calendar is a different issue,
but I'd assume pushing everything into an array numerically indexed by that day:
-- Example of how to include an if conditional in a where clause
-- We only want rows where a = 1 or 2 but only a = 2 if b = 4
-- table structure:
-- [ a | b ]
-- 1 4
-- 2 4
-- 1 5
-- 3 9
-- 2 7
<?php
/**
* Class do painel de administração do tema
* @author Rodolfo Silva <contato@rodolfosilva.com>
* @link http://rodolfosilva.com
*/
class ThemeAdmin
{
public function __construct()
{
@RodolfoSilva
RodolfoSilva / admin.php
Last active August 29, 2015 14:11
Método tema_config_page
<?php
/**
* Layout do painel
*/
public function theme_config_page()
{
?>
<div class="wrap">
<h2>Configurações do tema</h2>
<p>Pequena descrição sobre o tema e o painel de configurações do tema</p>
<?php
include_once TEMPLATEPATH . '/partials/admin.php';
$theme_admin = new ThemeAdmin();
<?php
/**
* Class do painel de administração do tema
* @author Rodolfo Silva <contato@rodolfosilva.com>
* @link http://rodolfosilva.com
*/
class ThemeAdmin
{
private $title = 'Configurações do meu tema';
private $name_id = 'config_theme';