How to get the filename and directory name of the shell script being run:
directoryName=${0%/*} #capture everything before the last / filename=${0##*/} #capture everything after the last /
How to get the filename and directory name of the shell script being run:
directoryName=${0%/*} #capture everything before the last / filename=${0##*/} #capture everything after the last /
Disambiguation of {braces parentheses brackets}
note: they are all types of brackets
from Wikipedia
Recently I came across the “Cut” and “Paste” commands in Linux. Man, these are useful tools as they allow you to rearrange your data from an existing file.
And now to make my life easier in Windows, I have found a SourceForge project that has ported many of these commands to Windows.
Find it at: http://unxutils.sourceforge.net/. Very Nice!
The list of UNIX/Linux commands available in the download I got:
agrep.exe
ansi2knr.exe
basename.exe
bison.exe
bzip2.exe
bunzip2.exe
bzip2recover.exe
cat.exe
chgrp.exe
chmod.exe
chown.exe
cksum.exe
cmp.exe
comm.exe
compress.exe
cp.exe
csplit.exe
cut.exe
date.exe
dd.exe
df.exe
diff.exe
diff3.exe
dirname.exe
du.exe
echo.exe
egrep.exe
env.exe
expand.exe
expr.exe
factor.exe
fgrep.exe
find.exe
flex.exe
fmt.exe
fold.exe
gawk.exe
make.exe
grep.exe
gsar.exe
gunzip.exe
gzip.exe
head.exe
id.exe
install.exe
join.exe
less.exe
ln.exe
logname.exe
ls.exe
m4.exe
md5sum.exe
mkdir.exe
mkfifo.exe
mknod.exe
mv.exe
mvdir.exe
nl.exe
od.exe
paste.exe
patch.exe
pathchk.exe
pr.exe
printenv.exe
printf.exe
ptx.exe
recode.exe
rm.exe
rman.exe
rmdir.exe
sdiff.exe
sed.exe
seq.exe
sleep.exe
sort.exe
sh.exe
shar.exe
split.exe
stego.exe
su.exe
sum.exe
sync.exe
tac.exe
tail.exe
tar.exe
tee.exe
test.exe
touch.exe
tr.exe
uname.exe
unexpand.exe
uniq.exe
unrar.exe
unshar.exe
uudecode.exe
uuencode.exe
wc.exe
wget.exe
which.exe
whoami.exe
xargs.exe
yes.exe
zcat.exe
If you run Ubuntu and you get only a low screen resolution of 800x600 (and not the native resolution of your host machine), then what you may need are the “Guest Additions”.
Here is what you need to do:
1. Run Ubuntu in VirtualBox
2. Use the host key to get to the host OS (normally the right ctrl key). This will allow you to move your mouse out into the world of your actual machine.
3. Click on "Install Guest Additions" under the devices menu:
This should load up a window that will display the contents of Guest Additions cd.
If you do not see the above disk on your Ubuntu desktop, then you might have to mount the guest additions. Here is how:
Go to Devices –> Mount CD/DVD-ROM –> CD/DVD-ROM Image…
Go to the CD/DVD Images tab and Click on Add.
Browse to the Virtual Box folder and select the “VBoxGuestAdditions.iso” file.
Click on Select on the “CD/DVD Images” tab.
You should get the CD for VBoxAdditions on your Ubuntu desktop now.
4. Double click the CD to view its contents. Which should look like this (and have some more files).
5. Depending on your host system you will have to run one of the “VBoxLinuxAdditions-XXX.run” files.
6. Unfortunately, its not as simple as double clicking the file to run it (as it needs to be run as an admin). Here is what you need to do:
Open a terminal prompt (Applications –> Accessories –> Terminal)
Navigate to the CD drive (type cd /media/cdrom0/)
Type LS and you should see all the files in the folder:
Type sudo sh ./VBoxLinuxAdditions-x86.run (remember its case sensitive)
You should be prompted for your password. Ubuntu should then run for a short while installing everything and you will be asked to restart.
Once you restart, you should get your native resolution. If not check the display settings.
Note: I had to install the Guest additions 2 times to get the new resolution in my Ubuntu virtual installation.
Note 2: Additional good stuff: Your mouse is no longer captured by Virtual box – which means you can seamlessly move between the host machine and the virtual machine. Also, copy paste will work across the 2 machines too. (Very nice!)
Themes, backgrounds, gadgets to make your Windows 7 computer your very own.
http://windows.microsoft.com/en-US/windows/downloads/personalize
My vote is for “Bing’s Best” theme pack. Very nice.
1.
to march out from a narrow or confined place into open country, as a body of troops: The platoon debouched from the defile into the plain.
2.
Physical Geography.
a.
to emerge from a relatively narrow valley upon an open plain: A river or glacier debouches on the plains.
b.
to flow from a small valley into a larger one.
3.
to come forth; emerge.
via the GoogleSystem blog:
Here is a book-marklet that lets you download YouTube videos as MP4 files. (just drag the link on to your book-mark toolbar or right click and add to favorites).
Last week, one of my DNN installations all of a sudden started giving me the following error:
Typically, if you log in as an administrator, then you can view the error information. But in my case, I was unable to see any information. In fact, I was unable to log in to the DNN portal. Upon further investigation what I realized was that even the content was not being rendered.
The only information that I was able to find out was from the event log tables in the database, which had the following information:
So it looked like the error was being thrown in the “DotNetNuke.UI.Skins.Skin.InjectModule” method and it looked like a property or a method was being invoked on an object that was null. But the above information is not very helpful.
Without any other information, I decided to modify the DNN code so that I could add additional logging information to the InjectModule code to see what was going on. To do this, I decided to use a simple text file to log the information. VB.Net is not my primary development language so I had to look up the syntax to create a file in append mode:
Using writer As StreamWriter = New StreamWriter(Server.MapPath(".\log\") & "attempts.txt", True) 'call code in here InjectModule(......) writer.WriteLine("log info using writeline") End Using
Once I had the code modified to perform in-depth logging, I found out that the InjectModule method would use the LoadControl method to load a user-control into a page. But before that, it would need to create the container into which it needed to load the user control. In version 4.6.2 of the DNN code, the code never expects the container to be null (ctlContainer.FindControl(glbDefaultPane)) and in our case the ctlContainer object was turning up null and was causing the “Object reference not set to an instance of an object” error.
But why was ctlContainer turning up Null. Turns out some files in the “Portals\_default\Containers” folder and in the “admin\Containers” folder had gone missing. Unfortunately for us, even the default containers had gone missing and hence ctlContainer was turning up null.
I am not sure why the files in those folders got deleted (module mis-behaving, user error, etc), but it sure was hard to track down this bug and fix it. Luckily DNN is an open-source project and we were able to track down the issue by modifying the core code for this purpose.
If you find that your ViewState is unavailable to your user control in ASP.Net and if you loaded the user-control dynamically (using the LoadControl method), then check to make sure that you are dynamically loading the user-control in the OnInit method. Most people make the mistake of loading the user-control in the Page_Load method and the problem with that is that the state is loaded before the Page_Load method is called (see diagram below – Page_Load is the Load event). When the view state is loaded and processed, ASP.Net will look for the control and if it is there – it will fill it with the data from the view-state and if the control isnt available, then it will be ignored.
By loading the user-control in the Init event, you ensure that the control will be available when the LoadViewState method is called by the framework and it will then be filled out correctly with the values from the view-state. (This is usually followed by the Raise xxxx Events, where you typically check the value of the control to perform further processing).
If you find that the LoadViewState method is not being called, then it is most probably because your control it-self is not using the View-State. To ensure that it is called try and over-ride the SaveViewState method and save a dummy value to the view-state. After this the LoadViewState should begin getting called.
How to implement Scrum in 10 easy steps (Agile Software Development):
- Step #1: Get your backlog in order!
- Step #2: How to estimate your product backlog
- Step #3: Sprint Planning/clarify requirements
- Step #4: Sprint Planning/estimate tasks
- Step #5: Create a collaborative workspace
- Step #6: Sprint!
- Step #7: Stand up and be counted!
- Step #8: Track progress with a daily burndown chart
- Step #9: Finish when you said you would
- Step #10: Review, reflect, repeat...
A list of some very nice JQuery plugins to provide cool navigation features for your website: http://webdesignfan.com/26-jquery-plugins-for-superb-navigation/
I was searching for a better taskboard to use with Team Foundation Server (TFS) than the one that comes canned with the Scrum for Team System (SFTS) template (which is a static report) and I came across the Work Item Manager.
In one word – its AWESOME!!!!
Work Item Manager is a beta product from Telerik and it does much, much more than just being an interactive task-board (which it does very well). Apart from the task-board, it provides so much more functionality that in some ways it comes close to becoming a replacement for Team Explorer (although it runs on top of Team-Explorer and so you do need to have TeamExplorer installed on your machine).
The task-board not only allows you to review the different states in which your work-items are in, but also allows you to change state by dragging and dropping them in a different state swim-lane. You can add work-items, review work-items, filter them and a whole lot more. Another cool feature is the Project Dashboard, a constantly updating screen of project information – a great way to get a quick overview of the project.
The WIM is a very cool project and you should take a look at the video that Telerik has made demoing all its features. (video)
As a developer I use text files all the time to write out information to log application events. These logs become extremely valuable when I am trying to debug a problem (especially while an app is running in production).
Typically I used to load up the file in NotePad++, which would provide me with a notification everytime the log file changed, allowing me to decide if NotePad++ should reload the document. (TextPad also provides similar functionality).
Today, I came across an awesome tool called BareTail, that allows me to monitor log files in real-time. BareTail automatically updates itself as the log file changes and it can display lines that were added or deleted. BareTail almost feels like a video player that is streaming what is happening to your log file.
Apparently, the origin of the name Bare-Tail is from the UNIX tool that provides similar capability called “tail” (run as tail –f).
It is definitely a tool that you should add to your dev-tools box.
BareTail - http://www.baremetalsoft.com/baretail/
NotePad++ - http://notepad-plus.sourceforge.net/uk/site.htm
The data that is used by TFS in its reports is stored in a SQL Analysis Services database. This data is stored in an OLAP cube. The cube is not update in real-time, which is the reason that TFS sometimes shows out of date information in its reports.
Fortunately, there is a way to request* for the cube to be updated. To do this, you need to log in to your TFS server. Open a browser and browse to:
http://localhost:8080/Warehouse/v1.0/WarehouseController.asmx
Select the “Run” method, then click the Invoke button.
You should receive a XML response with the value true in it. A value of true signals that the OLAP update process has been started. Now to determine when the update process has completed, you can invoke the “GetWarehouseStatus” method. This will return the values “Idle” or “Processing Olap”. The ware-house is refreshed once you get the Idle response status.
*The reason that I said “request” is that in practice I have found that Sql Server Analysis Services does not always begun refreshing the cube and will always return the Idle response. In this case – go home and come back the next day – by when it should update the cube.
Sometimes the default and automatic center positioning of a jQuery dialog upon opening does not work.
jQuery("#dialogDiv").dialog({ height: 'auto', modal: true, width: 400, autoOpen: false, position: 'center' });
I found the following code works to position the jQuery UI dialog in the center of the screen:
var x = document.body.clientWidth / 2; var y = document.body.clientHeight / 2; var dlg = jQuery("#dialogDiv"); dlg.dialog('option', 'position', [x, y]); //dlg.dialog('option', 'position', 'center'); dlg.dialog('open');
Had to really weird DotNetNuke (DNN) issues to work through that had me working most of this weekend.
The first one had to do with what manifested as a javascript error - “this.container.parentnode is null or not an object”
The issue turned out to be because I was using the JQuery javascript library. The library provides the $ macro as a shortcut to jQuery. But DNN already uses the $ macro, which causes issues. Fortunately, the fix is simple. Call the following method in a script block in the head of the document:
jQuery.noConflict();
This stops jQuery from trying to use the $ alias. Which means that you cannot use the $ alias to select DOM objects. Instead, whereever you use $ to work with JQuery, you need to directly reference the library using “jQuery”.
eg: $(document) becomes jQuery(document)
The second issue had to do with ViewState and a user control that was loaded using LoadControl
In other words, the user-control was being loaded dynamically using the LoadControl module. For the most part, the control was working. What was not working was the ListBox was not keeping its SelectedItem value, after I had selected an item in the ListBox and then clicked a button that caused a post-back.
After running around in many many circles, the thought that I have is that its because the ViewState is not working correctly. (The user-control works fine if I directly reference the user-control in a aspx page. The problem only occurs when the user-control is added dynamically using the LoadControl module).
The way I worked around this issue is that whenever I added items to the ListBox, I stored the items to the Session object. I then over-rode the OnInit method, and use the items in the Session object to load into the ListBox. The reason that I think this solution works is that the view-state is not working correctly and so I am giving the control a helping hand by filling it with the values that it should have after a post-back. All other events occur after the OnInit method has been called, allowing the SelectedItem to be correctly set.
From Camberely Bates presentation at the New Tech group (video):
For who: Identify your customer
Does what: what problem does it solve or how does it improve my life/job
Unlike: what differentiates you from the competition
Since last night, my iPhone had started acting weirdly. Every 3rd party application that I attempted to use would start up and immediately shut down. The only applications that worked were the ones that came with the iPhone originally.
Most posts that I read prescribed that I wipe out the iPhone and reinstall everything – that would take too long and didnt sound like the way I wanted to spend my weekend. So on a whim I tried a couple of steps and voila! all applications began working again.
Here are those steps:
1. Perform a complete shut-down of the iPhone. (Hold the round button on the face and the power button on the top of the iPhone for a few seconds and the iPhone will perform a hard shut down).
2. Start up the iPhone.
3. Now install some new app that you dont have already on your iPhone.
4. Try opening one of the apps that wasnt working. (Cross your fingers, cause if it doesn't work – then you might be out of luck and might have to do a complete reinstall). If the app does work – then rejoice – you just kicked the iPhone back into behaving correctly.
JQuery attribute filters make it easy to select and modify particular attributes in your HTML DOM.
For example: if you wanted to hide all links in a page, here is what you need to do
$("a[href]").toggle();
But what if you need to hide only some of the links on your page?
Maybe the one that links to “http://www.ai.com/”
$("a[href='http://www.ai.com/']").toggle();
Maybe all the ones that have google in the href….
$("a[href*='google']").toggle();
(the key to above filter is the “*” – which matches anywhere in the attribute’s value)
Maybe all the ones that end with org
$("a[href$='org']").toggle();
(the key to the above filter is the “$” – which matches to the end of the attribute’s value)
Maybe all the ones that begin with http://doc
$("a[href^='http://docs']").toggle();
(here the the key is the “^” character – which matches only to the beginning of the attribute’s value)
Here are important points to remember:
I always wondered how Shaazam worked (the app that automagically identifies songs). And today, I came across this document by one of the Shaazam creators that explains how it works:
http://www.ee.columbia.edu/~dpwe/papers/Wang03-shazam.pdf
The basic idea is that it uses a songs spectrogram (a graph of time on the x axis, frequency on the y axis) to generate a signature for each song. Samples uploaded from phones are converted to a spectrogram and compared against a database of pre-generated spectrograms to figure out information about the songs.
4 useful tutorials on using Fluent for NHibernate.
A fluent interface to NHibernate - Part 1
A fluent interface to NHibernate - Part 2 - Value Objects
A fluent interface to NHibernate - Part 3 - Mapping Relations
A fluent interface to NHibernate - Part 4 – Configuration
Also, remember, Fluent is an interface to NHibernate, so you can do anything you could do with NHibernate. A good example is performing queries. I searched all over for information on how to perform queries using Fluent for NHibernate and didnt find any. And then when it dawned on me that I could use NHibernate, I found a ton of resources.
Here is one from NHibernate’s documentation pages: https://www.hibernate.org/hib_docs/nhibernate/html/querycriteria.html
PhotoSketch: Internet Image Montage from tao chen on Vimeo.
Read more about PhotoSketch on ZDNet - http://blogs.zdnet.com/weblife/?p=965
Get the source code from: http://cg.cs.tsinghua.edu.cn/montage/files/Binary.zip
Here is the code to create a ISessionFactory that can be used to work with a SqlServer database
ISessionFactory sessionFactory = Fluently.Configure()
.Database( MsSqlConfiguration.MsSql2008
.ConnectionString(m => m.Server(@".\SqlExpress")
.Database("Fluent_Test")
.TrustedConnection()))
.Mappings(m =>
m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly()))
.ExposeConfiguration((Configuration config) => new SchemaExport(config).Create(false,true))
.BuildSessionFactory();
return sessionFactory;
The code uses a local SqlExpress database called “Fluent_Test”. The mappings are stored in the same assembly as the method in which the above code is placed.
Get more advanced tips from: http://technet.microsoft.com/en-us/magazine/2009.10.77windows.aspx