Skip to content

Instantly share code, notes, and snippets.

View halles's full-sized avatar

Matías Halles halles

View GitHub Profile
@halles
halles / wp-config-autoconfig.php
Created May 8, 2014 02:17
Autoconfig site url in wp-config.php
<?php
if(!isset($_SERVER['HTTPS'])){
$port = 80;
$protocol = 'http';
}else{
$port = 443;
$protocol = 'https';
}
1 10.0.1.1 (10.0.1.1) 0.340 ms 0.156 ms 0.140 ms
2 reverso.190.215.128.operaciones.gtdinternet.com (190.215.128.1) 34.644 ms 44.184 ms 31.231 ms
3 190.196.124.153 (190.196.124.153) 38.119 ms 41.142 ms 43.004 ms
4 ci1.te1-2.v219.cn1.gtdinternet.com (190.196.125.29) 37.911 ms 43.716 ms 44.738 ms
5 tengigabitethernet9-3.ar3.scl1.gblx.net (64.209.88.25) 44.038 ms 46.435 ms 39.566 ms
6 64.208.27.190 (64.208.27.190) 166.688 ms 171.863 ms 176.721 ms
7 ae-5.r04.lsanca03.us.bb.gin.ntt.net (129.250.2.220) 179.205 ms 179.298 ms 183.230 ms
8 ae-0.gtt.lsanca03.us.bb.gin.ntt.net (198.173.172.6) 216.907 ms 205.152 ms *
9 ae1-80g.cr1.lax1.us.nlayer.net (69.31.127.129) 200.698 ms
ae0-50g.cr1.lax2.us.nlayer.net (69.31.124.84) 214.628 ms
bash-3.2$ cd ~
bash-3.2$ brew unlink freetype
Unlinking /usr/local/Cellar/freetype/2.5.1... 0 links removed
bash-3.2$ brew unpin freetype
Warning: freetype not pinned
bash-3.2$ brew rm freetype
Uninstalling /usr/local/Cellar/freetype/2.5.1...
bash-3.2$ cd /usr/local/Cellar/freetype/
bash-3.2$ ls -al
total 0
@halles
halles / gist:5571768
Created May 13, 2013 21:41
Función para validar RUT. Retorna true o false.
<?php
function validarRut($rut){
$rut = $rut['id_number'];
$temp = explode('-',$rut);
$digito_v = $temp[1];
@halles
halles / gist:5571750
Created May 13, 2013 21:39
Función para Sanitizar RUT Chile (Añade puntos, guiones y convierte la k a mayúsucula en caso de no serlo.
<?php
function sanitizarRut($rut){
$temp = explode('-',$rut);
if (!isset($temp[1]) || $temp[1] == ''){
$temp[0] = substr($rut,0,strlen($rut)-1);
$temp[1] = substr($rut,strlen($rut)-1);
}
$digito_v = $temp[1];
$digito_v = ($digito_v=='k')?'K':$digito_v;
@halles
halles / less.force-recompile.js
Created April 23, 2012 23:26
Force Less.js to recompile CSS at polling time (defaults to less.poll = 1500ms)
less.watch();
less.optimization = 0;
jQuery(document).ready(function(){
cache = null;
less.watchTimer = setInterval(function () {
if (less.watchMode) {
console.log('Forcing Compile');
less.refresh(true);
}
}, less.poll);
@halles
halles / .htaccess
Created March 7, 2012 15:15
Add www at the beginning of a domain using .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.halles\.cl$ [NC]
RewriteRule ^(.*)$ http://www.halles.cl/ [R=301,L]
@halles
halles / obliterate-posts.php
Created January 17, 2012 18:14
WordPress: Script for deleting several posts based on some conditions. (Author: Gurthg @ irc.feenode.net #wordpress)
<?php
add_action( 'admin_init', 'iworks_dtl' );
function iworks_dtl(){
global $wpdb;
$query = 'SELECT ID FROM '.$wpdb->posts.' WHERE LENGTH(post_content) < 800 AND post_type = "post" AND post_status = "publish"';
$data = $wpdb->get_results( $query );
foreach( $data as $one ) {
wp_delete_post( $one->ID, true );