you are in: codestackercodes [RSS] → tag: leozera [RSS]

succ method Delicious Email

from: http://www.ruby-doc.org/core/classes/String.html#M000795

show/hide lines
   1  >> "abb".succ
   2  => "abc"
   3  >> "1".succ
   4  => "2"
   5  >> "1999zzz".succ
   6  => "2000aaa"
   7  >> 
created by leozera — 01 July 2009 — get a short url — tags: ruby embed

hirb example Delicious Email

to install:
gem install cldwalker-hirb —source http://gems.github.com

show/hide lines
   1  >> require 'hirb'
   2  => []
   3  >> Hirb.enable
   4  => nil
   5  >> Exam.find(:all, :limit => 5)
   6  +----+----------+----------+----------+----------+---------+----------+------+
   7  | id | title    | exam     | creat... | updat... | user_id | categ... | hits |
   8  +----+----------+----------+----------+----------+---------+----------+------+
   9  | 1  | Simul... | Simul... | 2009-... | 2009-... | 1       | 1        | 152  |
  10  | 2  | Simul... | Simul... | 2009-... | 2009-... | 1       | 1        | 143  |
  11  | 3  | Espec... | Espec... | 2009-... | 2009-... | 1       | 1        | 1089 |
  12  | 4  | Espec... | Espec... | 2009-... | 2009-... | 1       | 1        | 80   |
  13  | 5  | Espec... | Espec... | 2009-... | 2009-... | 1       | 1        | 40   |
  14  +----+----------+----------+----------+----------+---------+----------+------+
  15  5 rows in set
  16  >>
created by leozera — 01 July 2009 — get a short url — tags: gem hirb rails ruby embed

listing files in a directory with rails Delicious Email

show/hide lines
   1  @files = Dir.glob("public/files/*")
   2  
   3  for file in @files
   4      puts file
   5  end
created by leozera — 28 June 2009 — get a short url — tags: rails ruby embed

cross-browser transparency using css Delicious Email

show/hide lines
   1  .class {  
   2      filter:alpha(opacity=50);  
   3      -moz-opacity:0.5;  
   4      -khtml-opacity: 0.5;  
   5      opacity: 0.5;  
   6  }
created by leozera — 21 June 2009 — get a short url — tags: css embed

email regex Delicious Email

show/hide lines
   1  validates_format_of :email, 
   2  :with => /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/, 
   3  :message => "is invalid" 
created by leozera — 21 June 2009 — get a short url — tags: rails validation embed

list all jquery function with firebug Delicious Email

show/hide lines
   1  $(document).ready(function() { jQuery.fn.each( function(i) { console.log(i); }); });
created by leozera — 21 June 2009 — get a short url — tags: firebug firefox javascript jquery embed

jquery twitter Delicious Email

http://ralphwhitbeck.com/content/binary/twitter-json-jquery.html

show/hide lines
   1  <html>
   2  <head>
   3  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
   4  <script>
   5  	$(document).ready( function() {
   6  	
   7  		var url = "http://twitter.com/status/user_timeline/RedWolves.json?count=3&callback=?";
   8  		$.getJSON(url,
   9          function(data){
  10  			$.each(data, function(i, item) {
  11  				$("img#profile").attr("src", item.user["profile_image_url"]); 
  12  				$("#tweets ul").append("<li>" + item.text.linkify() + " <span class='created_at'>" + relative_time(item.created_at) + " via " + item.source + "</span></li>");
  13  			});
  14          });
  15  	});
  16  	
  17  	String.prototype.linkify = function() {
  18  		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
  19      return m.link(m);
  20    });
  21   }; 
  22    function relative_time(time_value) {
  23  	  var values = time_value.split(" ");
  24  	  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
  25  	  var parsed_date = Date.parse(time_value);
  26  	  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
  27  	  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
  28  	  delta = delta + (relative_to.getTimezoneOffset() * 60);
  29  	  
  30  	  var r = '';
  31  	  if (delta < 60) {
  32  	    r = 'a minute ago';
  33  	  } else if(delta < 120) {
  34  	    r = 'couple of minutes ago';
  35  	  } else if(delta < (45*60)) {
  36  	    r = (parseInt(delta / 60)).toString() + ' minutes ago';
  37  	  } else if(delta < (90*60)) {
  38  	    r = 'an hour ago';
  39  	  } else if(delta < (24*60*60)) {
  40  	    r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
  41  	  } else if(delta < (48*60*60)) {
  42  	    r = '1 day ago';
  43  	  } else {
  44  	    r = (parseInt(delta / 86400)).toString() + ' days ago';
  45  	  }
  46  	  
  47  	  return r;
  48  }
  49  function twitter_callback ()
  50  {
  51  	return true;
  52  }
  53  
  54  </script>	
  55  </head>
  56  <body>
  57  	<div id="tweets">
  58  		<img id="profile">
  59  		<ul></ul>
  60  	</div>
  61  </body>
  62  </html>
created by leozera — 10 May 2009 — get a short url — tags: javascript jquery twitter embed

short css Delicious Email

show/hide lines
   1  body {
   2  	background: #[hex-color] url([image URL]) [repeat] [attachment] [position];
   3  }
   4  
   5  p {
   6  	font: [style] [variant] [weight] [size]/[line-height] [family], [family];
   7  }
created by leozera — 10 May 2009 — get a short url — tags: css embed

cool link effect with css Delicious Email

show/hide lines
   1  a {
   2  	background-color:#fff;
   3  	border-width:1px;
   4  	border-style:solid;
   5  	border-bottom-color:#aaa;
   6  	border-right-color:#aaa;
   7  	border-top-color:#ddd;
   8  	border-left-color:#ddd;
   9  	border-radius:3px;
  10  	-moz-border-radius:3px;
  11  	-webkit-border-radius:3px;
  12  	-webkit-box-shadow:2px 2px 2px #bbb;
  13  	
  14  	padding: 10px;
  15  }
  16  a:hover {
  17  	border-top-color:#aaa;
  18  	border-left-color:#aaa;
  19  	border-right-color:#ddd;
  20  	border-bottom-color:#ddd;
  21  	-webkit-box-shadow:0 0 0;
  22  }
created by leozera — 01 May 2009 — get a short url — tags: css embed

short url in wordpress with tinyurl Delicious Email

paste the function in function.php file and call in you template with:

<?php echo ‘’.getShortUrl(get_permalink($post→ID)).‘“>short url’; ?>

show/hide lines
   1  function getShortUrl($url) {
   2    $tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
   3    return $tinyurl;
   4  }
created by leozera — 26 April 2009 — get a short url — tags: php tinyurl wordpress embed
Displaying records 1 - 10 of 132