Skip to content

Instantly share code, notes, and snippets.

@oriolrivera
oriolrivera / index.php
Created December 1, 2014 00:38
Cortar una Imagen con PHP
<?php
$filename= "ejemplo-de-imagen.jpg";
list($w, $h, $type, $attr) = getimagesize($filename);
$src_im = imagecreatefromjpeg($filename);
$src_x = '0'; // comienza x
$src_y = '0'; // comienza y
$src_w = '100'; // ancho
$src_h = '100'; // alto
@oriolrivera
oriolrivera / rangodate.html
Created October 20, 2014 20:14
rango de fecha con jquery ui
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
<script type="text/javascript">
//<![CDATA[
//alert(diferencia);
@oriolrivera
oriolrivera / today.js
Created October 15, 2014 20:43
jQuery Get Todays Date dd/mm/yyyy
var fullDate = new Date()
console.log(fullDate);
//Thu Otc 15 2014 17:25:38 GMT+1000 {}
//convert month to 2 digits
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) :(fullDate.getMonth()+1);
var currentDate = fullDate.getDate() + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
console.log(currentDate);
//15/10/2014
@oriolrivera
oriolrivera / date.js
Last active August 29, 2015 14:07
Fecha y Hora en Javascript
var fecha = new Date();
alert("Día: "+fecha.getDate()+"\nMes: "+(fecha.getMonth()+1)+"\nAño: "+fecha.getFullYear());
alert("Hora: "+fecha.getHours()+"\nMinuto: "+fecha.getMinutes()+"\nSegundo: "+fecha.getSeconds()+"\nMilisegundo: "+fecha.getMilliseconds());
@oriolrivera
oriolrivera / banco.txt
Created October 14, 2014 02:30
las tazas de cambio de algunos bancos y la de banco central, se actualiza cada 8 horas.
BANCO CENTRAL se extrae del pdf publicado diariamente
http://api.marcos.do/central_bank_rates
BANCO POPULAR
BANCO LOPEZ DE HARO
BANCO DEL PROGRESO
BANCON RESERVAS
euro_mean and dollar_mean == promedio del todos los banco
http://api.marcos.do/rates
@oriolrivera
oriolrivera / index.php
Created September 10, 2014 15:35
Calcula el numero de dias entre el rango de dos fechas.
<?php
// Calcula el numero de dias entre el rango de dos fechas.
function convertDateToInteger($dateInit, $dateEnd){
return ((strtotime($dateEnd)-strtotime($dateInit))/86400);
}
echo convertDateToInteger("09/10/2014","09/14/2014");
?>
@oriolrivera
oriolrivera / borrarfolder.php
Created September 6, 2014 22:14
Borrar folder y contenido
<?php
function deldir($dir){
$current_dir = opendir($dir);
while($entryname = readdir($current_dir)){
if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){
deldir("${dir}/${entryname}");
}elseif($entryname != "." and $entryname!=".."){
unlink("${dir}/${entryname}");
}
@oriolrivera
oriolrivera / zoom.html
Created September 1, 2014 01:44
efecto zoom con css
<style type="text/css">
.zoom{
transition: 1.5s ease;
-moz-transition: 1.5s ease; /* Firefox */
-webkit-transition: 1.5s ease; /* Chrome - Safari */
-o-transition: 1.5s ease; /* Opera */
}
.zoom:hover{
transform : scale(2);
-moz-transform : scale(2); /* Firefox */
/ Móviles en horizontal o tablets en vertical
------------------------------------------------------------------------- /
@media (min-width: 768px) { }
/ Tablets en horizonal y escritorios normales
------------------------------------------------------------------------- /
@media (min-width: 1024px) { }
/ Escritorios muy anchos
@oriolrivera
oriolrivera / index.php
Created August 19, 2014 16:15
get tasa dolar google
<?php
public static function getTasaDolar($from, $to, $amount){
$content = file_get_contents('https://www.google.com/finance/converter?a='.$amount.'&from='.$from.'&to='.$to);
$doc = new DOMDocument;
@$doc->loadHTML($content);
$xpath = new DOMXpath($doc);