One line shell script to delete all lines starting from a specific pattern to the end of file


At work today I had to run a lot of SQL files which had  –-//@UNDO  followed by SQL commands to rollback the transactions  carried out at the top of the file. This is standard for SQL migration files, However MySQL server errors out when it encounters this. I used a quick shell script to remove all the –//@UNDO and all the SQL commands which followed it.

for i in *; do echo "Processing" $i; sed '/\-\-\/\/@UNDO/,$d' $i > /tmp/$i; done;

The above line will delete all lines starting from –-//@UNDO until the end of file. The modified contents are then written to /tmp. The original file remains unchanged.

Huge list of computer science simulations


While searching for information on Finite Automata & languages, I found this page which has a huge set of Java simulations on every core topic related to concepts in computer science.

  1. Elementary Data Structures
  2. Trees
  3. Recursion
  4. Elementary Sorting Methods
  5. Quicksort
  6. Priority Queues / Heaps
  7. Mergesort
  8. Elementary Searching Methods
  9. Balanced Trees
  10. Hashing
  11. File Compression
  12. General (Terms) About Graphs
  13. Elementary Graphs Algorithms
  14. Connectivity
  15. Weighted Graphs
  16. Directed Graphs
  17. Network Flow
  18. Finite State Machine

If you are new to CS or trying to just remember things these simulations are of great help.

Powered by ScribeFire.

XUL pages from around the web


I wanted to see how other people were using XUL and did a search on Google for “ext:XUL”

I found close to 15,400+ results here are a few pages that I found interesting

The above examples are not much to look at but if you are learning XUL then they are a great help, in case you want to downlaod any of the XUL code just open the link in IE and you can download and examine the code.

UC Berkley online lectures


UC Berkley has put the entire lecture notes for some computer science courses online and completely free for you to download and enjoy. The site contains both vid-casts and podcasts of each lecture. This can be a great resource for a undergrad/grad student who just wants to review the basics or learn more about a course he intends to take.

Here are the relevant links

Operating Systems and System Programming
The Structure and Interpretation of Computer Programs
Data Structures and Programming Methodology
Machine Structures

powered by performancing firefox

TrackMeNot + Firefox = anonymous searching


After AOL released user search data last year and the chaos that ensued have led to increased concern among users of being profiled by search engines. If you would like to thwart these search engines from profiling you, you should get the TrackMeNot extension.The extension periodically queries designated search engines with random keywords and thus provides bogus data to the search engine which in turn totally messes with the search engines profiling.

If this extension is used along with Tor and Privoxy it can cloak you in an extra layer of privacy. This is one of the must have extensions for those who value their privacy.

powered by performancing firefox

Anonymous browsing with Tor and Firefox


If you are worried about your privacy and would like to browse the internet anonymously then you should consider using Tor in conjunction with Firefox. This great software includes a router and privoxy (a proxy server) which can mask user IP affording you to browse the web safely and anonymously. Foxtor and torbutton Firefox extensions allow you to enable and disable tor and privoxy from within the Firefox browser.

foxtor.jpg

here’s how you install all three

1. Download and install tor from this link.
2. Download and install either Foxtor or Torbutton.
3. Start tor from the system tray
4. Click on the foxtor or torbutton icon to toggle anonymous browsing.

keep in mind that you should not use tor with BitTorrent or other P2P software to download illegal software.

powered by performancing firefox

Monster XUL resource roundup


A lot has changed since my last XUL related post, several new tools now exist
that can help you learn XUL more effectively while many a good resource like
www.georgenava.com
have gone down.

INTRODUCTION TO XUL

What is XUL

An introduction to XUL

XUL TUTORIALS

Mozilla developer center’s XUL tutorial

Building applications with XUL and javascript

Create Web applets with Mozilla and XML

XUL: The Future of User-interfaces on the Web

HOWTO: Getting Started with Linux Standalone Apps using XUL

XUL Element preview and reference

XUL planet example viewer

XULWareHouse Project.

Writing Skinnable XUL and CSS

XUL REFERENCE

XUL planet Element reference

Mozilla developers center-XUL reference

FIREFOX EXTENSION TUTORIALS

Nerdshift-Firefox extensions tutorial

BornGeek-Firefox toolbar tutorial

How to create Firefox extensions

Setting up extension development environment

Enabling Extension Updates

Firefox Extension Development Tutorial

Captain’s Mozilla XUL LOG – read local files and write local files

XUL, XPI and Firefox/Mozilla extensions

XUL BOOKS

Creating Applications with Mozilla

Rapid Application Development with Mozilla

XUL TOOLS

Extension Developer’s Extension

XPI Maker

XULRunner

XUL explorer

XUL tools and what they mean

eclipseXUL – XUL Support for Eclipse

LiveXUL editor

XULBooster- another eclipse plugin for XUL

FireBig

XULKit

XUL Widgets

GUID Generator (From the evil corporation)

FIREFOX LINKFEST (HUGE COLLECTION OF LINKS RELEATED TO FIREFOX AND XUL PUT TOGETHER BY OTHER GUYS)

Ilias.ca

XUL annotations

XUL alliance

XUL Starter…

XUL BASED APPLICATIONS

Mozilla amazon browser v1.4.

code-etch editor

Firefox File-manager

xulRecordset

XUL based Editor

Sunbird

Songbird

FireFox

Democracy player (there is a XUL port of the democracy player)

REMOTE XUL

Remote XUL applications with PHP

Creating XUL applications with PHP

Creating Rich Web Applications by Connecting XUL with PHP

FIREFOX HACKS

Fun with Chrome

Modifying Firefox’s Context Menus

Firefox Kiosk browser

Firefox XUL kiosk browser script (shameless self linking 🙂 )

XUL CHEAT SHEETS

XUL Widget Cheat-sheet

XUL Button Cheat-sheet

Hope this helps you and sets you on your way to XUL mastery…..

Kiosk browsing – update


A couple of months ago I posted about trying to get a Kiosk up and running with XUL, Turns out that the method I suggested does not work too well. Here is what I did to get it working

1. Use customize to remove address bar.
2. Clear out the bookmarks.
3. Use the tutorial here to lock the homepage to the page you want.
4. If needed remove the navigation bar as well.
5. Install R-kiosk from here.
6. Setup your mac/windows to disable loading any other browser.
7. Setup Firefox to auto load on startup.
8. Additionally you can install Public fox for much greater control.

However be aware that a sufficiently savvy user can circumvent all this by calling the browser from the command line with the desired website as an argument.

powered by performancing firefox

Kiosk mode browser using XUL


I volunteer at the Warren memorial library and was asked recently to create a Kiosk mode browser that could not be used to browse anything else except for the library’s book catalog. I started exploring the various options available and soon settled on two browsers, Opera and Firefox, while it is fairly easy to setup opera in kiosk mode you still need to pay Opera for the professional version to make it work.That ruled out opera and I was left with Firefox.I started hunting around for an extension that would turn the Firefox browser into a locked down version where you could not navigate to any site. I downloaded the R-Kiosk extension this extension does a pretty decent job of locking down the browser.The extension disables most of the menu items and does a pretty good job in disabling the navigation bar and the address bar,but the extension fails to block the preferences menu item thus leaving a chink in its armor which can be exploited by anyone who is computer savvy. The person can use the preferences menu to set the home page to any desired site close preferences and hit alt+home on the keyboard to navigate to that page.

For e.g if you wanted to restrict the patron from visiting any other site except for the library’s own home page a malicious user could set the home page to something like http://www.google.com and navigate to any site from there. The author also claims that the extension can only be uninstalled from safe mode, but by going to http://addons.mozilla.com and installing any addon you still get access to the addons window and can uninstall the extension from there.

In the end I found that the only way to circumvent these issues was to disable almost all the menu items, this was too much work which included hacking the perf.js file in the profiles folder so I decided to write a XUL widget instead.

Here is the XUL code

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
id="google's Online catalog"
title="googleOnline catalog"
orient="horizontal"
width="1000"
height="768"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<vbox flex="1">
<hbox pack="center">
<html:font face="verdana" color="blue">
<html:strong>
<label value="Google's online catalog"/>
</html:strong>
</html:font>
</hbox>
<hbox flex="1" orient="vertical">
<html:iframe src="http://books.google.com/" flex="1"></html:iframe>
</hbox>
</vbox>
</window>

PS: Copy pasting the code above will not work please download the code here, for some reason the code tag in wordpress does not work with XUL code 😦 properly. once you download the file from the above link rename the file from kiosk.doc to kiosk.xul.

you can preview the above code in this excellent XUL live editor.

googlexul.jpg

On a Mac you can setup a restricted account, set it to auto login without password and then set Firefox to start this XUL file at login. to further prevent access to the OS install the profile password extension for Firefox. This is not an elegant solution but it got the job done.

The XUL file can be started on login with the following command line typed into a shell script

cd /
cd Applications
cd Firefox.app
cd Contents
cd MacOS
./firefox -chrome /nameofxulfile.xul

On a windows machine the default shell can be changed to something like Blackbox which is a minimal shell and can be used for the same purpose, but it isn’t foolproof the only other way is to set the shell as Firefox which I haven’t found a way to do yet.

powered by performancing firefox