Skip to content

Instantly share code, notes, and snippets.

View felipelavinz's full-sized avatar

Felipe Lavín Z. felipelavinz

View GitHub Profile
@felipelavinz
felipelavinz / the_doc_type.php
Created November 17, 2009 18:30
Helper function to determine the document type
<?php
/**
* Get document type based on the mime type
* (Loosely) based on wp_ext2type() on WordPress
*
* @param Object|string $attach WordPress object for an attachment or mime type
* @param boolean $echo Whether to echo (true) or return (false) the out
* @return string Three-letter file type, based on MIME-Type groups, or 'file' if there's no match
*/
tallestTable = 0;
$('#team-list li').each(function(){
if ( $(this).height() > tallestTable ) { tallestTable = $(this).height(); };
})
if (msie.msie6) $('#team-list li').css({'height': tallestTable});
else $('#team-list li').css({'min-height': tallestTable});
@felipelavinz
felipelavinz / gist:242051
Created November 24, 2009 17:43
convertir imágenes en un directorio
for i in *.png; do convert $i -resize 50x50 $i.jpg; done
@felipelavinz
felipelavinz / get_by_name.php
Created November 24, 2009 18:24
Get stuff by name (WordPress)
<?php
/**
* Get stuff ID by nicename
* @param $nicename string The nicename (i.e: post-slug) to get the ID for
* @param $type string The table that will be queried: posts (default), term, users
* @return integer The ID for the requested object, false if nothing found
*/
function get_by_name($nicename, $type="posts"){
global $wpdb;
if ( empty($type) OR $type === 'post'){
@felipelavinz
felipelavinz / relativize_path.php
Created January 24, 2010 05:14
simple function to relativize request to a WP site
<?php
/**
* Return the request path, relative to the WP base URL
* @param boolean $return_parts Return as a string or an array
* @return string|array The relative request OR array with relative "directories"
*/
function relativize_url($return_parts=true){
$wp_url = get_bloginfo('url'); //base URL for this WordPress site
$wp_url_parts = parse_url($wp_url); //
@felipelavinz
felipelavinz / buscDef.js
Created April 12, 2010 04:23
Simple jQuery plugin to set sample content on text inputs and automatically clean it on focus
/**
* A simple jQuery plugin to set sample content on text inputs
* and automatically clean it on focus
* @author Basilio Cáceres <bcaceres@ayerviernes.com>
* @author Felipe Lavín <flavin@ayerviernes.com>
*/
jQuery.fn.buscDef = function() {
var orVal = jQuery(this).val();
if ( jQuery.trim(orVal) != '' ) {
jQuery(this).data( 'defVal', orVal )
@felipelavinz
felipelavinz / antispambot_sc.php
Created April 20, 2010 01:00
A simple plugin to use WordPress' antispambot() function in posts and pages
<?php
/*
Plugin Name: Antispambot Shortcode
Plugin URI: http://yukei.net/proyectos/nospam-sc
Description: A simple plugin to use WordPress' antispambot() function in posts and pages
Version: 1.0
Author: Felipe Lavin Z.
Author URI: http://www.yukei.net
*/
var cookieHelper = {
/**
* Create a new cookie and add it to the document
* @argument name {string} The "key" name of the cookie
* @argument value {string} The "value" of the cookie
* @argument days {number} The number of days this cookie should be kept
* @author Peter-Paul Koch <quirksmode.org>
*/
create : function(name,value,days) {
if (days) {
@felipelavinz
felipelavinz / dateHelper.js
Created May 13, 2010 14:05
A very simple class for some basic dates operations in Javascript
/**
* A very simple class for some basic Date operations
* @author Felipe Lavín <www.yukei.net>
*/
var dateHelper = {
arrToDate : function(arr, format){
/**
* Convert an array to a Date object
* @argument arr {Array} An array containing at least day-month-year
* @argument format {String} An string representation of the date format. Default: dd-mm-yyyy. More could be added as necessary
inoticoming --foreground . python ~/.gnome2/nautilus-scripts/PyShare_GTK ~/tmp/screenshots/{} \;