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 / set-value.md
Created July 28, 2012 22:04 — forked from JeffreyWay/set-value.md
PHP: Set value if not exist

You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:

name = name || 'joe';

This is quite common and very helpful. Another option is to do:

name || (name = 'joe');
@fabiancarlos
fabiancarlos / email_utf8.md
Created July 23, 2012 14:34
force utf-8 mail
function mail_utf8($to, $subject = '(No subject)', $message = '', $header = '') {
  $header_ = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
  mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
}
@fabiancarlos
fabiancarlos / web.config
Created July 19, 2012 20:01
Kohana 3.2 URL Rewrite of the IIS 7/Windows 2008 **using conversor of .htaccess to web.config
<!--# link: http://learn.iis.net/page.aspx/470/importing-apache-modrewrite-rules/ -->
<configuration>
<system.webServer>
<rewrite>
<rules>
<!--# Turn on URL rewriting-->
<!--# Protect hidden files from being viewed-->
<!--# Protect application and system files from being viewed-->
<rule name="Imported Rule 9" stopProcessing="true">
<match url="^(?:application|modules|system)\b.*" ignoreCase="false" />
@fabiancarlos
fabiancarlos / subir.js
Created June 21, 2012 15:29
Pequeno script para subir para topo (JS)
//element - elemento que ao clicar, sobe ao topo automaticamente e suavamente ex: $('#subir')
function subirSuavemente(element){
"use strict";
element.click(function(event){
$('html, body').animate({scrollTop:0}, 'slow');
event.preventDefault();
});
}
// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@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);
@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 / 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 / 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 / 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+');