Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Acts as Taggable on Steroids: tag cloud rhtml + view helper

// description of your code here
controller layout (base) stylesheet update
  <%= stylesheet_link_tag 'scaffold', 'tag_cloud' %>


create stylesheet, put it in ./public/, name it tag_cloud.css or similar
/* tag_cloud styles*/
.nube1 {font-size: 1.0em;}
.nube2 {font-size: 1.2em;}
.nube3 {font-size: 1.4em;}
.nube4 {font-size: 1.6em;}
.nube5 {font-size: 1.8em;}
.nube6 {font-size: 2.0em;}


partial template call
        TAG CLOUD<br/>
        <%= render(:partial => "shared/article_tag_cloud", :locals => {:tags => @tags}) %>

view template code, as a partial or within index/show action template
        <% # For our purposes, have this filter the list of articles to those with the chosen tag
                tag_cloud true, tags, %w(nube1 nube2 nube3 nube4 nube5) do |name, css_class| %>
                <%= link_to name, tag_path(name), class => css_class # links to Tag resource, with tag name as 'id'
                %>
        <% end %>

helper code
        def tag_cloud(active, tags, classes)
                if !active then return end
                max, min = 0, 0
                unless tags.empty?
                        tags.sort! {|x,y| y.count <=> x.count}
                        max = tags.first.count
                        min = tags.last.count                      
                end
        
                divisor = ((max - min) / classes.size) + 1
        
                tags.each { |t|
                        yield t.name, classes[(t.count.to_i - min) / divisor]
                }
        end

mimimee 123

// description of your code here

index.php
<html>
        <head>
                <script type="text/javascript" src="modul - clock.php">script>
                



"".date("d-m-Y")."<br>".date("H:i:s").""; /*NECESAR pentru a inlocui delay-ul pana ce se incarca script-ul*/?>
"clock" style="position:relative;">



technorati multi-word tagging bookmarklet : my custom modification

// Replace BLOGNAME with your own blog name. If input is "javascript, text snippets, code" without quotes, output is "Tags: t javascript, t text snippets, t code, t BLOGNAME" with appropriate technorati tag links. span class is tectag. To find posts tagged javascript and code in your Blogger blog, search for ("t javascript" AND "t code") without paranthesis from the Blogger search box at the top, or search for (tag:javascript tag:code) from Technorati.
// This is a compressed and modified version of the bookmarklet code at http://consumingexperience.blogspot.com/2005/07/technorati-tag-creator-for-multiple.html

javascript:(
function(){
var a=' Tags: ';
var t=prompt('enter:','')+', BLOGNAME';
var tr=t.split(',');
for(var i=0;i<tr.length;i++){
        if(i>0){a+=', ';}
        tr[i]=tr[i].replace(/^\s*|\s*$/g,'');
        a+='t '+tr[i].replace(/\s/g,'+')+'\" rel=\"tag\">'+tr[i]+'';
}
prompt('copy:',a+'');
}
)()
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed