Skip to content

Instantly share code, notes, and snippets.

View fabiancarlos's full-sized avatar
🚀
Go!

Fabian Carlos fabiancarlos

🚀
Go!
View GitHub Profile
@fabiancarlos
fabiancarlos / Conta.java
Created May 11, 2012 21:20
Pequena class de exemplo de incremento e decremento de um valor
public class Conta{
private double saldo;
public Conta(double saldo){
this.saldo = saldo;
}
public void depositar(double valor){
@fabiancarlos
fabiancarlos / image_upload_kohana.php
Created May 13, 2012 09:11
upload the image ~ Kohana 3.2 ~ FIX BUG "Kohana_Exception [ 0 ]: Not an image or invalid image:"
<?php
# protected $_path = 'media/images/uploads/produtos/';
# $produtos = new Model_Produtos;
# $time_now = new DateTime();
// validation file image
$files = Validation::factory($_FILES)
->rule('imagem', 'Upload::not_empty')
->rule('imagem', 'Upload::type', array(':value', array('jpg','jpeg','png','gif','JPG','JPEG','PNG','GIF')))
->rule('imagem', 'Upload::image');
@fabiancarlos
fabiancarlos / Pessoa.java
Created May 13, 2012 22:55
5 pessoas declaram suas cores favoritas
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JOptionPane;
public class Pessoa {
public static void main(String[] args) {
String[] pessoas = new String[5];
@fabiancarlos
fabiancarlos / enviar.php
Created May 25, 2012 23:07
exemplo enviar via get
<a href="teste.php?resposta=sim" >REPOSTA GET</a>
<?php
$resposta_get = $_GET['resposta'] ? $_GET['resposta'] : 'SEM PARAMETRO NA URL';
echo $reposta_get;
?>
@fabiancarlos
fabiancarlos / multi_up.php
Created May 27, 2012 19:37
upload the image ~ Kohana 3.2 com plugin multi.js
<?php
// validation file image
$files = Validation::factory($_FILES)
->rule('imagem', 'Upload::type', array(':value', array('jpg', 'png', 'gif')));
// if file image is not empty, just do it bob!!! =:^D
if ($files->check() && !empty($_FILES['imagem']['name'][0])){
// pega o ultimo ID do servicos
@fabiancarlos
fabiancarlos / triggers_procedures_ifmt.sql
Created June 7, 2012 23:32
Algumas triggers, procedures do banco Passagens Aereas
-- author: Fabian Carlos
-- INSERT para testar as triggers
-- INSERT INTO "passageiros" VALUES(333, 'Fabian Carlos');
-- insert into "voo" VALUES(1);
-- insert into "aeronaves" VALUES(1,'Boing 747');
-- insert into "cidades" VALUES(1, 'Cuiabá', 'Brasil');
-- insert into "aeroportos" VALUES(1, 'Aeroporto VG', 1);
-- insert into "assentos" VALUES(1, 'AA+');
@fabiancarlos
fabiancarlos / enviar_form_email.php
Created June 10, 2012 23:30
Enviar formulario para email via php
<html>
<head>
<title>ENVIO PARA EMAIL</title>
</head>
<body>
<?php
$nome = (!empty($_GET['nome'])) ? $_GET['nome'] : false;
$email = (!empty($_GET['email'])) ? $_GET['email'] : false;
@fabiancarlos
fabiancarlos / money_format.js
Created June 14, 2012 21:30
Formatar para tipo em dinheiro (JS)
var c, n, s, i, j;
Number.prototype.formatMoney = function(c, d, t){
n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d === undefined ? "," : d, t = t === undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
@fabiancarlos
fabiancarlos / trim.js
Created June 14, 2012 21:45
Remover todos espaços em branco (JS)
String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
};
@fabiancarlos
fabiancarlos / pre_message.js
Created June 14, 2012 22:31
Pré mensagens para inputs (jQuery)
function preMessage(id_input, message_input){
"use strict";
id_input.val(message_input);
id_input.focusin(function(){
checkInputFormsNull($(this), message_input);
});
id_input.focusout(function(){
checkInputFormsNull($(this), message_input);