Skip to content

Instantly share code, notes, and snippets.

@javiertapia
javiertapia / jetbrains-md-preview.css
Created June 23, 2026 16:56
Markdown CSS for Jetbrains previews
/*
Adapted from https://github.com/sindresorhus/github-markdown-css
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@javiertapia
javiertapia / gist:3709436
Created September 12, 2012 19:51
Activar links dentro de un texto
/*
Busca las urls (http://..., www...) y direcciones de correo electrónico dentro de un texto
y los rodea con los tags <a> correspondientes.
*/
function activar_links($text){
$text = preg_replace("/(^|[\n ])([\w]*?)([\w]*?:\/\/[\w]+[^ \"\n\r\t<]*)/is",
"$1$2<a href=\"$3\" >$3</a>", $text);
$text = preg_replace("/(^|[\n ])([\w]*?)((www)\.[^ \"\t\n\r<]*)/is",
"$1$2<a href=\"http://$3\" >$3</a>", $text);
$text = preg_replace("/(^|[\n ])([\w]*?)((ftp)\.[^ \,\"\t\n\r<]*)/is",
@javiertapia
javiertapia / gist:3707164
Created September 12, 2012 14:53
(PHP5) Extract Zip file
$fn = explode('.', $_FILES['archivo']['name']);
$ext = array_pop($fn);
if($ext == 'zip'){
$files = array();
$zip = new ZipArchive();
if( $zip->open($_FILES['archivo']['tmp_name']) ){
for($i=0; $i<$zip->numFiles; $i++){
$file = $zip->statIndex($i);
$files[] = $file['name'];
}
@javiertapia
javiertapia / jquery.validate.rut.js
Created February 16, 2009 14:03
Validar rut mediante jQuery.Validate
function validaRut(campo){
if ( campo.length == 0 ){ return false; }
if ( campo.length < 8 ){ return false; }
campo = campo.replace('-','')
campo = campo.replace(/\./g,'')
var suma = 0;
var caracteres = "1234567890kK";
var contador = 0;