Skip to content

Instantly share code, notes, and snippets.

@tonysm
tonysm / app_model.php
Created March 30, 2012 00:53
last error - database validation
<?php
class AppModel extends Model {
public function retornaErro(){
$db = ConnectionManager::getDataSource('default');
return $db->lastError();
}
}
var line = new RGraph.Line('chart1', charts.data);
line.Set('chart.labels', this.labels);
line.Set('chart.linewidth', 3);
line.Set('chart.key', charts.keys);
line.Set('chart.colors', charts.colors);
line.Set('chart.contextmenu', [
['Zoom', RGraph.Zoom],
['Edit', function(){
RGraph.Reset( line.canvas );
RGraph.Clear( line.canvas );
@tonysm
tonysm / InscricoesController.php
Created May 24, 2012 17:04
Exemplo de listagem de models associados
<?php
class InscricoesController extends AppController {
//seus códigos
...
public function inscricao (){
$tipos = $this->Inscricao->Tipo->find('list');
$this->set(compact('tipos'));
@tonysm
tonysm / MyApp.store.Users.js
Created July 13, 2012 13:57
Example of extjs store
Ext.define('MyApp.store.Users', {
extend: 'Ext.data.Store',
requires: ['MyApp.model.User'],
model: 'MyApp.model.User',
storeId: 'Users',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'php/users/index.json',
reader: {
layout title date comments categories
post
Olá, mundo!
2012-07-14 13:19
true
Desenvolvimento
Octopress

Opa, galera, beleza? Esse é o primeiro post aqui no meu blog. Estou usando o Octopress, falarei aqui também sobre ele.

@tonysm
tonysm / BancoDeDados.php
Created July 20, 2012 15:03
Singleton Example
<?php
/**
* BancoDeDados
*
* Essa classe estabelece uma conexão com o banco de dados e também
* é responsável por fechar essa conexão. Nessa classe também é possível forçar uma nova conexão.
*
* @author Luiz Messias <tonyzrp@gmail.com>
*
*/
@tonysm
tonysm / routes.php
Created August 30, 2012 11:36
router and regular expressions
<?php
// first route
Router::connect(
'/:slug',
array(
'controller' => 'Startups',
'action' => 'view'
),
array(
'slug' => '[0-9A-Za-z_-]+Startup', //just an example
@tonysm
tonysm / index.html
Created September 6, 2012 13:15
rgraph issue
<html>
<head>
<title>Test rgraph</title>
<script type="text/javascript" src="rgraph/RGraph.common.core.js" ></script>
<script type="text/javascript" src="rgraph/RGraph.common.dynamic.js" ></script>
<script type="text/javascript" src="rgraph/RGraph.bar.js" ></script>
<script type="text/javascript" src="rgraph/RGraph.line.js" ></script>
<script type="text/javascript">
window.onload = function ()
@tonysm
tonysm / index.html
Created December 26, 2012 16:10
Validação de campos numéricos (sem jQuery). Incluindo controle de control C e control V (copy and paste)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS Validation</title>
<script src="jsvalidation.js"></script>
</head>
<body>
<h1>Validação de números</h1>
<p>Detalhe: não é possível também copiar e colar strings no campo, apenas números</p>
@tonysm
tonysm / UsuariosController.php
Last active June 3, 2022 13:00
dynamically creating inputs with CakePHP and jQuery
<?php
/**
* Controller de usuários
*/
class UsuariosController extends AppController
{
public function index()
{
if(isset($this->request->data) && $this->request->is('post')) {