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!)

About this user

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

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+'');
}
)()

C macro that implements count_if, sum, max_elem

// C macro that does count_if, sum, max_elem.

#define COUNT_IF(ITERATION, CONDITION, COUNT)  {COUNT =0; ITERATION {if(CONDITION) COUNT++;}}  
/* ex: COUNT_IF( for(i=0;i++;i<10), i%2==0, evens)  [counting the number of evens.]  */

#define SUM(ITERATION, EXPRESSION, SUMM)  {SUMM =0; ITERATION {SUMM +=(EXPRESSION);}}  
/* if ITERATION is an empty iteration, the sum is 0
SUM( for(i=0;i<60;i++) if(zik[i]==sol[i]) , score[i], actual_score ) */


#define MAX_ELEM(ITERATION, EXPRESSION, MAX_VALUE, POSITION)  { \
        bool first233496 = true;                                   \
        ITERATION {                                               \
                if(first233496){ first233496 = false; POSITION ; MAX_VALUE =(EXPRESSION); } \
                else if((EXPRESSION)> MAX_VALUE ){ POSITION ; MAX_VALUE =(EXPRESSION); }   \
        }                                               \
}
/* if ITERATION is an empty iteration, this macro does not work.
ex: MAX_ELEM(for(x=0;x<5;x++) for(y=0;y<5;y++) , x-2*y , maximum , {m_x=x;m_y=y;} );  [ Set (m_x,m_y,maximum) := (x,y,x-2*y) when x-2*y achieves maximum value] 
ex: MAX_ELEM( ON(i,10), (10-v[i])*v[i], d, k=i); */
« Newer Snippets
Older Snippets »
2 total  XML / RSS feed