Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Sigmus / congelados.json
Last active December 15, 2015 07:39
Congelados da Lenita.
[
{
"prato": "Escondidinho de frango e mandioquinha / arroz branco",
"preco": 21
},
{
"prato": "Carne cozida ao molho de cerveja / arroz sete grãos",
"preco": 21
},
{
/* Ajuste de altura googlemaps */
var $contato = $('.contato');
var $onde = $contato.find('.onde');
var $entre = $contato.find('.entre');
function ajustarAlturaMapa() {
$onde.height($entre.height());
}
ajustarAlturaMapa();
@Sigmus
Sigmus / orcamento.json
Last active December 16, 2015 01:59
Modelo Zeus.
{
"order":
{
"client": {
"name": "Thiago",
"phone": "3454534",
"email": "[email protected]",
"shipping": {"id": 1}
},
"orderItens":
@Sigmus
Sigmus / reais.php
Last active December 16, 2015 08:29
Return value in R$
<?php
/**
* Return value in R$
*
* @param float $value
* @return string
*/
function reais($value)
{
return number_format($value, 2, ',', '.');
@Sigmus
Sigmus / parcelas.php
Created May 7, 2013 14:08
Parcelas Moip.
<?php
/**
* Method addParcel()
*
* Allows to add a order to parceling.
*
* @param int $min The minimum number of parcels.
* @param int $max The maximum number of parcels.
* @param float $rate The percentual value of rates
* @param boolean $transfer "true" defines the amount of interest charged by MoIP installment to be paid by the payer
<EnviarInstrucao>
<InstrucaoUnica>
<Razao>Carrinho de compras Loja Modelo</Razao>
<IdProprio>compra1234</IdProprio>
<FormasPagamento>
<FormaPagamento>BoletoBancario</FormaPagamento>
<FormaPagamento>CarteiraMoIP</FormaPagamento>
<FormaPagamento>CartaoCredito</FormaPagamento>
<FormaPagamento>DebitoBancario</FormaPagamento>
<FormaPagamento>FinanciamentoBancario</FormaPagamento>
var validate_cpf = function(value) {
var cpf = value.replace('-', '').replace('.', '');
while(cpf.length < 11) cpf = "0"+ cpf;
var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/,
a = [], b = new Number, c = 11;
for (i=0; i<11; i++) {
a[i] = cpf.charAt(i);
<?php
private function priceTable($taxa, $quantParcelas, $valor)
{
$valor1 = $taxa * pow((1 + $taxa), $quantParcelas);
$valor2 = pow((1 + $taxa), $quantParcelas) - 1;
$pgto = $valor * ($valor1 / $valor2);
return $pgto;
}
<?php
// COMPRA REALIZADA
Event::listen('pedido.status.realizado', function($id)
{
Mailer::sendStatus($id, 'Pedido Realizado');
});
function best(fun, coll) {
return _.reduce(coll, function(x, y) {
return fun(x, y) ? x : y
});
}
best(function(x,y) {
return x > y
}, [1,2,3,4,5]);
// 5