Tag Archive for define

Define and call a function in interactive mode

#Define a function
>>> def hola():
        print "hola mundo"

#Call the function
>>> hola()
hola mundo

source

Ninjawords Bookmarklet

javascript:(function(){function t(f){try{if(f.getSelection)return f.getSelection().toString();if(f.document.selection)return f.document.selection.createRange().text}catch(e){}return ''}function getQ(f){var q=t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');var s='';for(var i=0;i<f.length;i++){s=getQ(f[i]);if(s)q+=(q?',':'')+s}return q}if(window.location.hostname!='ninjawords.com')window.open('http://ninjawords.com/'+getQ(window.top));else{document.getElementById('q').value = getQ(window.top);Ninjawords.textboxQuery()}})()

//Here it is expanded so you can read it:
javascript:(function(){
function t(f)	//get the selected text in frame f
{
try{
if(f.getSelection) return f.getSelection().toString();
if(f.document.selection) return f.document.selection.createRange().text;
}catch(e){}	//if the frame is in another domain
return '';
}
function getQ(f)	//get the selected text in frame f and its children
{
//get rid of non-alphanumeric characters and separate words with commas
var q = t(f).replace(/^[^a-z0-9-]+|[^a-z0-9-]+$/ig,'').replace(/[^a-z0-9-]+/ig, ',');
var s = '';
for(var i=0; i<f.length; i++)	//for each child frame
{
s = getQ(f[i]);
if(s) q += (q?',':'')+s;
}
return q;
}
if(window.location.hostname != 'ninjawords.com')	//if not already at ninjawords.com
window.open('http://ninjawords.com/'+getQ(window.top));
else
{
document.getElementById('q').value = getQ(window.top);
Ninjawords.textboxQuery();
}
})()

source

gcc defines

gcc -E -dM -x c /dev/null

source

size_t define

typedef unsigned int size_t;

source

C++ NULL define

#define NULL ((void *)0)

source