Skip to content

Instantly share code, notes, and snippets.

@eveevans
eveevans / ruby-http-header
Created September 21, 2011 16:32
http headers
require 'rubygems'
require 'net/http'
url = URI.parse('http://laurel.datsi.fi.upm.es/index.php')
req = Net::HTTP::Get.new(url.path)
req.add_field 'Range', 'bytes=714-732'
res = Net::HTTP.start(url.host, url.port) {|http|
@eveevans
eveevans / indicador cargando
Created October 17, 2011 18:54
// plugin para indicador de cargando
// plugin para indicador de cargando
$.fn.showLoading = function(top, left) {
top = top || 0;
left = left || 0;
this.each(function() {
// crear indicador
var $this = $(this);
var offset = $this.offset();
offset.top += top;
offset.left += $this.width() + left;
@eveevans
eveevans / ruby-thumb.rb
Created November 16, 2011 23:26
Generacion de Miniaturas usando Ruby e Image Magick
# Ruby, Generacion de minuaturas usando Image Magick
i = 0
full = "1200x900"
thumb = "320x240"
images = Dir.entries(".")
images.each do |file|
if file.match(/\.jpg$/i)
@eveevans
eveevans / application.html.erb
Created February 16, 2012 18:31
Rails Breadcrumb
<%= make_breadcrumb(yield :breadcrumb) %>
@eveevans
eveevans / jquery.split_in_span.js
Created March 13, 2012 21:03
jquery extension for split element words into span
/*! split_in_span v1 | flasheves.com */
jQuery.fn.extend({
split_in_span: function(){
var arr = jQuery(this).text().split(' ');
var tamo = arr.length;
for(i=0;i<tamo;i++){ arr[i] = '<span>' + arr[i] + '</span>'; }
jQuery(this).html(arr.join(' '));
}
});
@eveevans
eveevans / StreamSave.rb
Created May 10, 2012 23:06
Ruby script for save mp3 stream
require 'rubygems'
require 'net/http'
require 'uri'
BIT_RATE = 48 #6kbxseg * 60 seg (a min) * 15min
TAMO_CORTE = (BIT_RATE/8) * 60 * 15 #en KB
url = URI.parse('http://186.1.15.253:8000/')
Net::HTTP.start(url.host, url.port) do |http|
@eveevans
eveevans / jsmin.c
Created June 20, 2012 21:22
download, compile and put jsmin in the path, mode of use: jsmin < application.js >application.min.js
#!/bin/sh
TEMP_DIR="/tmp/jsmin"
SRC_FILENAME="http://www.crockford.com/javascript/jsmin.c"
SRC_BASENAME="jsmin.c"
BIN_BASENAME="jsmin"
BIN_DIR="/bin"
mkdir $TEMP_DIR
cd $TEMP_DIR
@eveevans
eveevans / LineaCat
Created August 3, 2012 21:17
WP Widget para mostrar subcategorias y post dada una cat padre
<?php
/**
* Widget Post: Marca Labs - LineaCat
* MLWidgetLineaCat Class
*/
class MLWidgetLineaCat extends WP_Widget {
function MLWidgetLineaCat() {
parent::WP_Widget(false, $name = 'ML Widget Cat', array('description' =>__( 'Muestra post y subcategorias de una categoria padre','')));
}
@eveevans
eveevans / galería wp
Created August 3, 2012 21:28
extraer todas las imagenes asociadas de un post
<h1><?php the_title() ?></h1>
<?php
$images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
if ( $images ) :
?>
<?php foreach($images as $ima): ?>
<div class="gallery-thumb ev-gallery">
<a rel="ev-gallery" class="size-thumbnail" href="<?php echo wp_get_attachment_url($ima->ID); ?>"><?php echo wp_get_attachment_image( $ima->ID, 'thumbnail' ); ?></a>
@eveevans
eveevans / gist:3430390
Created August 22, 2012 22:55
Browser, editable mode
javascript:document.body.contentEditable='true'; document.designMode='on'; void 0