Friday, May 29, 2009

7zip Batch Zip

First, make sure that the 7zip directory is in your path. Usually, it is located at

C:\Program Files\7-Zip

Next, write the following in batch file

Zip all files in a directory

for /f %%A in ('dir /b') do 7z a -tbzip2 "%%A.bz2" "%%A"

Zip files with a specific extension in a directory (download batch file)

for /f %%A in ('dir /b *.txt *.dat') do 7z a -tbzip2 "%%A.bz2" "%%A"

Save and run in the directory where you want to zip the files.

Here, I am compressing using bzip2 (notice the switch: –tbzip2). You can change that to

-tzip for zip

-tgz for gz

-t7z for 7z

some more examples here.


Cite as:
Saad, T. "7zip Batch Zip". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/7zip-batch-zip.html

Restart Windows in Remote Desktop

press:

Alt + F4

Voila!


Cite as:
Saad, T. "Restart Windows in Remote Desktop". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/restart-windows-in-remote-desktop.html

Thursday, May 21, 2009

How to Add a Watermark in Latex

More often than not, I like to place a “DRAFT” watermark on my documents. This can be easily and automatically done by just including a specific package (one for PS and one for PDF).

Here’s how

\usepackage[draftcopy] % for PS and DVI

\usepackage[pdfdraftcopy] % for PDF

Voila!

For the documentation of draftcopy check here.

For the documentation of pdfdraftcopy check here.


Cite as:
Saad, T. "How to Add a Watermark in Latex". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/how-to-add-watermark-in-latex.html

Tuesday, May 19, 2009

Wolfram Alpha

It has been finally released!

http://www.wolframalpha.com/

I’m too sleepy now to experiment with it.

In the meantime, you can check the walking randomly blog.


Cite as:
Saad, T. "Wolfram Alpha". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/wolfram-alpha_19.html

Friday, May 15, 2009

How to Cite a Blog & Automatically Generate Citations for your Blog

The MLA format for citing a blog is:

Last Name, First. "Title of Entry." Weblog Entry. Title of Weblog. Date Posted. Date Accessed (URL).

You can find more information on studenthacks and on the Purdue website.

Now comes the fun part. If you’re familiar with the Wolfram mathworld website, there is a “CITE THIS AS” section at the bottom of every page (example). I wanted to reproduce something similar for my blog. As you may have already noticed, there is a “Cite as” box at the bottom of every post. Of course, I didn’t go over every post to add a cite-as box. I used the google blogger API to automatically add this to every post. Here’s how you can reproduce it for your own blog

  1. Go to the “Edit HTML” section for your template
  2. Enable the “Expand Widget Templates” check box
  3. Scroll down (or search: Ctrl + f) for
    <data:post.body/>
    This may require some tweaking as your template may be different. The idea is to locate the “post body” section – right after the body text of your post.
  4. Copy the following HTML code:
    <!-- BEGIN CITE AS CODE - BY T. SAAD -http://pleasemakeanote.blogspot.com --> 
    <br/>
    <p style='border-width:1px;border-style:solid;border-color:orange; padding:4px'>
    <font color='orange'>
    Cite as:
    <br/>
    LAST NAME, FIRST NAME &quot;<data:post.title/>.
    &quot; Weblog entry from <a href='http://LINK-TO-YOUR-BLOG> <data:blog.title/></a>.
    <a expr:href='data:post.url'><data:post.url/></a>
    </font>
    </p>
    <br/>
    <!-- END CITE AS CODE –>

  5. Save your template

Voila! Don’t forget to put your name and the link to your blog. You can easily modify the above script with little HTML and CSS knowledge.


Cite as:
Saad, T. "How to Cite a Blog & Automatically Generate Citations for your Blog". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/how-to-cite-blog-automatically-generate.html

Modifying Mathematica Menus

UPDATE - FRIDAY MAY 15, 2009
The same procedure applies for Mathematica 7.x - just look in the 7.0 directory. For convenience, I posted the Mathematica 7.0.1 modified menu file. Of course, there is no guarantee that this will work on your end, so by all means do backup your copy of the MenuSteup.tr file before using this one. You can download it from here.

UPDATE - MONDAY JUNE 02, 2008
As was kindly pointed out by an anonymous comment, Mathematica version 6.0.2 includes the "Evaluate Notebook" menu item. Also, removing the backup files from the MenuSetup directory is a must. - Thanks

In Mathematica 6.x, a couple of nice features are missing, namely, the "Evaluate Notebook" menu command and the placement of the "Quit Kernel" command. First, the "Evaluate Notebook" is completely missing form the "Evaluation" menu - and I don't see the reason for removing such a useful command from the new version. Regarding the "Quit Kernel", which is probably the most used command during a Mathematica session, is now located under Evaluation/Quit Kernel/Local. Instead of keeping that command one level higher (i.e. Evaluation/Quit Kernel), for some reason it was placed under a sub-menu.

Yesterday, I found out that one can modify the whole Mathematica menu, and in the process, add the "Evaluate Notebook" command and modify the location of the "Quit Kernel" command. Thanks to the Walking Randomly blog for sharing this information - you can find the original post here.

So here's what I have done on my end to make my Mathematica workspace fit to my needs.

  1. Locate the file "MenuSetup.tr" - This is usually found somewhere within the "Wolfram Research" directory. A simple search would be enough to find that file. (try C:\Program Files\Wolfram Research\Mathematica\6.0\SystemFiles\FrontEnd\TextResources\Windows\)
  2. Open "MenuSetup.str" with a text editor. In windows, I use wordpad to do that because it keeps the formatting correct and wraps the text quite nicely.
  3. Scroll down to the end of the file and locate the last brace-then-bracket "}]" then add the following before that
    1. Type a comma then go to a new line
    2. Insert the following
      Delimiter,
      Item["Evaluate &Notebook", "EvaluateNotebook"],
      Item["&Quit Local Kernel", "MenuListQuitEvaluators", MenuAnchor->True]
Voila!

You should be able to see two new menu items on the menu bar. Make sure also to backup your original MenuSetup.tr. If nothing shows up on the Mathematica menu, you might have to move the backup copy from the MenuSetup directory.

Cite as:
Saad, T. "Modifying Mathematica Menus". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2008/05/changing-mathematica-menus.html

Thursday, May 14, 2009

Calling Gnuplot from c Using Pipes... Again!

Here's another way of calling gnuplot. I like this method because it provides a standalone function that plots your results. Here's the code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void plotResults(double* xData, double* yData, int dataSize);
int main() {
int i = 0;
int nIntervals = 100;
double intervalSize = 1.0;
double stepSize = intervalSize/nIntervals;
double* xData = (double*) malloc((nIntervals+1)*sizeof(double));
double* yData = (double*) malloc((nIntervals+1)*sizeof(double));
xData[0] = 0.0;
double x0 = 0.0;
for (i = 0; i < nIntervals; i++) {
x0 = xData[i];
xData[i+1] = x0 + stepSize;
}
for (i = 0; i <= nIntervals; i++) {
x0 = xData[i];
yData[i] = sin(x0)*cos(10*x0);
}
plotResults(xData,yData,nIntervals);
return 0;
}
void plotResults(double* xData, double* yData, int dataSize) {
FILE *gnuplotPipe,*tempDataFile;
char *tempDataFileName;
double x,y;
int i;
tempDataFileName = "tempData";
gnuplotPipe = popen("c:\\gnuplot\\bin\\pgnuplot -persist","w");
if (gnuplotPipe) {
fprintf(gnuplotPipe,"plot \"%s\" with lines\n",tempDataFileName);
fflush(gnuplotPipe);
tempDataFile = fopen(tempDataFileName,"w");
for (i=0; i <= dataSize; i++) {
x = xData[i];
y = yData[i];
fprintf(tempDataFile,"%lf %lf\n",x,y);
}
fclose(tempDataFile);
printf("press enter to continue...");
getchar();
remove(tempDataFileName);
fprintf(gnuplotPipe,"exit \n");
} else {
printf("gnuplot not found...");
}
}


This code should run as is. Of course, feel free to take the plot function and use it in your own codes.

Cite as:
Saad, T. "Calling Gnuplot from c Using Pipes... Again!". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/calling-gnuplot-from-c-using-pipes.html

Wolfram Alpha

I can't wait for this to be released!

http://www.wolframalpha.com/index.html

In the meantime, check out this presentation by Stephen Wolfram himself



or this CNET demonstration


Cite as:
Saad, T. "Wolfram Alpha". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/wolfram-alpha.html

How to Call Gnuplot from c Using Pipes (Windows)

Try this:

// Open a pipe to gnuplot
FILE *gnuplotPipe = popen("c:\\gnuplot\\bin\\pgnuplot -persist","w");
// If gnuplot is found
if (gnuplotPipe) {
// using fprintf on the gnuplotPipe, we can directly issue commands in gnuplot
fprintf(gnuplotPipe, "set style data lines\n");
fprintf(gnuplotPipe, "cd 'C:\\gnuplot\\bin'\n");
// assuming your data file is placed in the gnuplot bin directory
fprintf(gnuplotPipe, "plot \"data-file.dat\" using 1:2\n");
fflush(gnuplotPipe);
fprintf(stderr,"Press enter to continue...");
fflush(stderr);
getchar();
// exit gnuplot
fprintf(gnuplotPipe,"exit \n");
pclose(gnuplotPipe);
}

Cite as:
Saad, T. "How to Call Gnuplot from c Using Pipes (Windows)". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/how-to-call-gnuplot-from-c-using-pipes.html

Tuesday, May 12, 2009

One year anniversary – Please Make a Note

Today marks the one year anniversary of Please Make a Note! This idea that started as a mere way of keeping track of how I accomplished certain tasks so that I can refer to them later has had an unexpected (positive) outcome: the number of visitors to this blog. Although I had wished (as everybody who owns a blog does) to reach as many online users as possible, I had never expected the current results. I am also quite pleased with the several hits that PMAN received from some important bloggers and software companies (yes!!! PMAN was visited by Mathematica people!).

In any event, I would like to thank all those who have shown interest in this blog. I hope that you found some useful posts here.

This is the monthly visits report from statcounter (12 May 2008 – 12 May 2009).

image

(P.S. I have no idea what happened in march!)

Page Loads Unique Visitors First Time Visitors Returning Visitors
Total
41,947 27,326 23,797 3,529
Average/month
3,227 2,102 1,831 271

Voila!


Cite as:
Saad, T. "One year anniversary – Please Make a Note". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/one-year-anniversary-please-make-note.html

Monday, May 4, 2009

How to Flatten or Embed Comments in a PDF using Acrobat©

Most often than not, I implement all my comments to PDF files (such as manuscript proofs) using the many rich features of Adobe’s Acrobat Professional. However, I always prefer to “flatten” these comments that is, make them a permanent part of the PDF document. There are a few methods for doing this, but by far, the fastest and most clever is this one, found on PlanetPDF

  1. In Acrobat professional, type “Ctrl + j” to invoke the java script dialog
  2. In that dialog, type: this.flattenPages();
  3. press “Ctrl + Enter”

Voila!

Don’t forget to save your document.


Cite as:
Saad, T. "How to Flatten or Embed Comments in a PDF using Acrobat©". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2009/05/how-to-flatten-or-embed-comments-in-pdf.html