Monday, October 13, 2008

BASH script for easier programming

How many of you are tired of going through with terminal cd-ing until finding the file you want to compile ?, typing in all those commands for gcc or g++ or even simpler things like python or java and wish that there was some kinda program that would just let you pick the damn file and compile without you having to strain yourself well now there is and also with a cool little gui i might add, so here it this will let you pick your file and then pick what kind of file it is, ie .c .cpp .py etc .... and then just run just like that it is a very simple script nothing fancy, but it just might save you those extra key strokes you always hated to begin with.

just to mention the script can be easily adapted to any other programming language that i didnt add.

README FIRST

should copy this file and put it in a folder, it'd be best to be in your home directory just for easy access if you wanted it to run from terminal, remember to give this file executable permissions and watch it go, always choose to run in terminal when double clicking on it.

Next update of this script will be done sometime in the next couple of weeks. I will be posting the list of new updates soon as well.

any bug reports should be done here thank you.


#!/bin/sh

#
# Simple script to compile and run anytype of file.
#
# Rapsodia49 rapsodia49@gmail.com 2008
#
# 100% opensource
#

filevar="./var"
filevar2="./var2"


if [ -e $filevar ];
then
rm var
fi

if [ -e $filevar2 ];
then
rm var2
fi


SelectFile=$(zenity --file-selection --title "Select a File");echo $SelectFile



if [ -z $SelectFile ];
then
zenity --info --text "No File selected"

else

zenity --info --text "\"$SelectFile\" selected"


ans=$(zenity --list --text "Select the type of file" --radiolist --column "Pick" --column "Type" TRUE C FALSE Shell FALSE "C++" FALSE "Java" FALSE python FALSE Ruby); echo $ans

case $ans in
"C") echo "Compiling and running C File ";
gcc $SelectFile -o var;
./var;
rm var;;

"C++") echo "Compiling and running C++ File ";
g++ $SelectFile -o var2;
./var2;
rm var2;;

"Java") echo "Compiling and running Java File ";
java $SelectFile;;

"python") "Compiling and running Python File ";
python $SelectFile;;

"Shell") "Compiling and running Shell File ";
./$SelectFile;;
"Ruby") "Compiling and running Ruby File ";
ruby $SelectFile;;
esac
fi

Monday, October 6, 2008

Ubiquity is awesome

So this new add-on for Firefox came out, btw one of my favorite next to gspace, anyways. it is very cool because it lets you do whatever the heck you want and I must say this is one of the reasons I use it and one of the reasons I use Linux as well.

Ubiquity (as they have called it) is very simple to use very nice user interface for all of you out there and I found it very easy to code for as well. I am not going to do a full review of Ubiquity for mainly three reasons one you can find all I am going to say about it in its wiki at https://wiki.mozilla.org/Labs/Ubiquity, two I am not a native english speaker so that makes it harder and three I just dont want to.

here are some of the Ubiquity sripts are wrote with the help of some simple tutorial found on the net somewhere credits to all them( I am not gonna list them all sorry guys, but thanks anyways )

Facebook Search

makeSearchCommand({

name: "Facebook",

url:"http://www.facebook.com/s.php?ref=search&init=q&q={QUERY}",
icon:"http://ads.ak.facebook.com/ads2/flyers/51/39/6002218418094_1_bc58a359.jpg",
description: "Searches Facebook for anything realated.",
preview: function(pBlock, directObj) {
if (!directObj.text || directObj.text.length < 1) {

pBlock.innerHTML = "Search Facebook.";
return;
}

pBlock.innerHTML = "Search Facebook for <code>" + directObj.text + "</code>";
var url = "http://www.facebook.com/";
var params = { facebook: directObj.text, mode: "suggest" };

jQuery.get(url, params, function(data) {
var preview = "Searched Facebook for <code>" + directObj.text + "</code>:";
var results = data[1];
for (var i = 0; i < results.length; i++) {
var name = results[i];
var url ="http://www.facebook.com/s.php?ref=search&init=q&q=" + escape(name);
preview += "<br
/><code><u><a
href=\""+url+"\">" + name +
"</a></u></code>";

}


pBlock.innerHTML = preview;

}, "rapsodia49");

}

});



Shoutcast Search

makeSearchCommand({

name: "Shoutcast",

url:"http://shoutcast.com/directory/search_results.jsp?searchCrit=simple&s={QUERY}",
icon: "http://classic.shoutcast.com/images/sc-logo.gif",
description: "Searches Shoutcast for song or artist.",
preview: function(pBlock, directObj) {
if (!directObj.text || directObj.text.length < 1) {
pBlock.innerHTML = "Search Shoutcast.";
return;
}

pBlock.innerHTML = "Search Shoutcast for <code>" + directObj.text + "</code>";
var url = "http://www.shoutcast.com/";
var params = { shoutcast:directObj.text, mode: "suggest" };
jQuery.get(url, params, function(data) {
var preview = "Searched Shoutcast for <code>" + directObj.text + "</code>:";
var results = data[1];
for (var i = 0; i < results.length; i++) {
var name = results[i];
var url = "http://shoutcast.com/directory/search_results.jsp?searchCrit=simple&s="
+ escape(name);

<!-- preview += "<br
/><code><u><a
href=\""+url+"\">" + name +
"</a></u></code>";

}
pBlock.innerHTML = preview;
}, "rapsodia49");
}
});










Now if you have installed the Ubiquity add-on already use your hot-key to bring the terminal usually ctrl+alt+space and type command-editor then simply copy and paste the sript you want to use and try it out for yourselves

steps to follow after script has been put in command-editor

bring out the ubiquity command line and type facebook then type w/e you wanna search for in facebook, it works whether you are logged in or not.

do the same for shoutcast