Monday, August 15, 2016

Blogger: How to Add Advanced Font Selector for Header Description

Template Designer: Advanced: Blog Description Color Selector

I will show you how to add an Advanced Font Selector for the header description in Blogger so you can change the font type & size separate from the header title.

As shown in the screenshot above, there is only a Selector to change the Description Color in the Blogger Template Designer.

  • First go to the overview of your blog and select "Template" from the left column menu. Then select the "Edit HTML" button below the "Live on Blog" preview.

  • Next, click on the whitespace in the editor and press Ctrl+F to drop down the find bar.

  • Type "Blog Description" in the find field (without the quotes) and press enter. This should show "Blog Description" highlighted in the editor like in the screenshot below.

Finding Text in the Template Editor

  • To add a new Variable tag for the Description Font, enter following text in the editor, below the opening Blog Description Group tag.
<Variable name="description.font" description="Font" type="font" default="normal normal 16px Arial, Tahoma, Helvetica, FreeSans, sans-serif" value="normal normal 16px Arial, Tahoma, Helvetica, FreeSans, sans-serif"/>
  • See the image below for where to place the Description Font Variable tag.

Adding a Description Font Variable tag

  • Now type "description" in the find field (without the quotes) and press enter. This should show the ".description" CSS selector, highlighted in the editor, like in the screenshot below.


Finding Text in the Template Editor

  • Now comment out the old CSS Description block as show in the image below.

Comment the Old CSS Description Block

  • Next, add the following text to create a customized CSS section above the CSS content section.
/* Custom
----------------------------------------------- */
.Header .description {
  font: $(description.font);
  color: $(description.text.color);
}
  • See the image below for where to place the the text.

Adding the Custom CSS Section With New Description Block

  • Now click the "Save template" button and click the "Back" button.

  • At the Template page, click the "Customize" button under the "Live On Blog" view to go to the Blogger Template Designer page.

  • Select "Advanced" on the menu and then "Blog Description" and you will now see a Font Selector like in the screenshot below.

Template Designer: Advanced: Blog Description Font & Color Selector

Enjoy!

Tuesday, September 22, 2015

How to Set up FreeGLUT on NetBeans IDE 8.1

I will show you how to setup FreeGLUT on NetBeans IDE 8.1 so that you can code OpenGL programs in C/C++ on Windows.

The first thing you need to do is install MinGW-w64, MSY2 (for GNU make.exe), and activate the C/C++ plugin. I already have a blog post with instruction how to do that here: How to Create a 64-bit C/C++ Windows Program with NetBeans 7.4, 8.0 or Higher. (Updated 04/18/2016) Note that this is to set up a 64-bit toolchain, but you can set up a 32-bit toolchain by using the 32-bit installations of MinGW and MSYS2. Although you can compile 32-bit programs with 64-bit MinGW, only the 64-bit glu32 library is included.  If your 32-bit program requires the glu32 library, you will need the 32-bit MinGW package.

FreeGLUT does not provide compiled libraries on their site, but one of the community developers offers the compiled library here: freeglut Windows Development Libraries. At the time of this writing, the latest package is freeglut-MinGW-3.0.0-1.mp.zip. This package works for building 64-bit or 32-bit programs. A 64-bit and 32-bit Windows dll (freeglut.dll) is included.
  1. Unzip the contents of the FreeGLUT zip file to a convenient location. In this example the path is "C:\Developer\mingw64\freeglut". The directory structure is show below:
FreeGLUT Directory Structure
  1. The project source code used in these instructions can be downloaded from here: Sphere Mapping Example.
  2. Extract the files to a folder named "FreeGlut-TeaPot".
  3. Delete the Makefile from the project folder because NetBeans will create it's own Makefile. There are other files you may delete from the folder, but it is not required. The following screenshot shows the required files for the project.
Required Project Files
  1. Next, create a C++ Application in NetBeans. Choose File >> New Project. Then under "Categories," choose "C/C++" and under "Projects," choose "C/C++ Application". See the following screenshot:
NetBeans 8.1 New Project Dialog Box
  1. Click "Next" and on the next dialog box and name the project the same name as the project folder from step 4. 
  2. Next, uncheck "Create Main File," since the project already has one. See the following screenshot.
NetBeans 8.1 New C/C++ Application Dialog Box
  1. Next you will add the source and header files to the NetBeans project's logical folders shown in the Project window. This is required so they are included in the project's classpath.  This is accomplished by right clicking on the "Source Files" folder and choosing "Add Existing Items...". Choose all files with "c" and "cpp" extensions. Do the same for the "Header Files" folder and add all the files that have an "h" extension. If you like, you can add the remaining image file to the "Resource Files" folder. The following screenshot shows what the project structure should look like.
NetBeans 8.1 FreeGlut-TeaPot Project Folder Structure
  1. You will now see project include errors because NetBeans does not know where the "glut.h" file is located. Right click on the project name in the Projects window and choose "Properties". Under Categories, click the "C Compiler" sub node and on the right you will see an "Include Directories" field. Click the "..." button and navigate to "C:\Developer\mingw64\freeglut\includes" and add the directory. Do the same for the C++ Compiler. See the following screenshot.
NetBeans 8.1 Project Properties: C++ Compiler
  1. Now NetBeans' code assistant will find the required header files and the project should not show any include errors. The code assistant will now be FreeGlut functional for this project only. 
  2. Next, choose the Linker sub nod and click the "..." button next to "Additional Library Directories". Navigate to "C:\Developer\mingw64\freeglut\lib\x64". (If you are using MinGW 32-bit, the 32-bit libraries are under the "\lib" folder.)
  3. On the same panel, enter the require linker options in "Additional Options". Since there is only one library folder, you can enter the linker options directly in the field, otherwise you would need to click the "..." button. Enter the options: -lfreeglut -lglu32 -lopengl32 -Wl,--subsystem,windows. See the following screenshot. 
NetBeans 8.1 Project Properties Dialog: Linker
  1. Choose the "Run" sub node and set the "Console Type" to "Standard Output". You may also set it to "External Terminal". 
  2. If you don't want the project to build every time you run it form NetBeans, uncheck "Build First". See the following screenshot.
NetBeans 8.1 Project Properties: Run
  1. Now you will be able to build the project. Right click on the project's name in the Project window and choose "Build". 
  2. After the project is done building, you should see "BUILD SUCCESSFUL..." in the Output window.
  3. Before you can run the project, you will need to make sure freeglut.dll is in your Windows system path or in the project's run directory. If you don't want to edit the Windows system path, you can put the dll in any folder that already in your system path or you can put it in the project's "/dist/release/MinGW-Windows" folder. (Note this folder does not exist until you build the project the first time.) Either way, make sure you are using the 64-bit dll for a 64-bit Windows program, and the 32-bit dll for a 32-bit program. 
  4. Now click on the project's name in the Project window and choose "Run". You should see a shiny tea pot as shown in the screenshot below.
OpenGL Sphere Mapping Example
You can zoom the tea pot by moving your mouse cursor left or right while simultaneously holding down the left and middle mouse button. You can spin the tea pot with your mouse cursor while holding down the left mouse button. You can also translate the tea pot by holding down the middle mouse button. (See the source code to reassign the buttons.)

For more information about using FreeGLUT, MSYS2 and MinGW-w64, please visit the following URLs:

Monday, February 23, 2015

Compiling, Running & Editing jEdit 5 in NetBeans 8.0

I will show you how to setup the jEdit 5 source code as a NetBeans 8.0.2 free-form project so you can compile it and do whatever you like with it.

You should have NetBeans 8.0.2 properly installed along with JDK 1.8.0_31. Apache Ant 1.9.4 is required and is included with NetBeans 8.0.2. You may also use an external installation of Apache Ant 1.9.4 or higher. In this example, we are using an external installation of it. In either case, the path to your Ant installation must be in your system path.
  1. Download the jEdit source code from the jEdit website.
  2. Create a new project folder called "jEditProject " or whatever name you would like to call it.
  3. Extract the jEdit files from the archive that you downloaded into the new project directory you created in step 2. You can use 7-Zip to decompress it. The folder structure will look similar to this:
jEdit 5.2 Source Folder Structure
  1. Run NetBeans and choose File >> New Project. Then under "Categories," choose "Java." Under "Projects" choose "Java Free-Form Project." See the following image:
NetBeans 8.0.2 New Project Dialog Box
  1. Click the Next button and in the next dialog box, set the "Location" to be the folder you extracted from step 2. The other fields will populate automatically. 
NetBeans 8.0.2 New Java Free-Form Project Dialog Box—Name and Location
  1. Click the Next button twice and you will see the "Source Package Folders." Set the Java "Source Level" to JDK 1.7 and the "Encoding" to UTF-8. Click the Finish button. See the following image:
NetBeans 8.0.2 New Java Free-Form Project—Source Package Folders
  1. NetBeans will scan the project to resolve dependencies. After NetBeans is done scanning, you will see red error badges appear on some of the packages. These are the packages that have members that cannot be resolved until the project build is run and dependencies are downloaded. See the following image:
NetBeans 8.0.2 Projects Window
  1. Next, right click on the project name and choose "Build" and dependencies are downloaded and the project is built.
  2. At this point you will still see error badges on some packages. These can be resolved by adding some of the JARs that were downloaded in step 9, to the project's classpath. You will also need to add "ant.jar" from your Ant installation and "tools.jar" from your JDK installation to the project's classpath. Right click on the project and choose "Properties" and then under "Categories" choose "Java Source Classpath." Add the Jars as shown in the following screenshot:
NetBeans 8.0.2 Project Properteis—Java Source Classpath
  1. There should not be any error badges now. If so, you may need to add more libraries to the classpath.
  2. Now expand the build.xml node in your project and find the target "docs-html." Right click on this node and choose "Run Target." This will build the jEdit help files. See the following screenshot:
NetBeans 8.0.2 Projects Window—Run docs-html Target
  1. There are some packages and files that may be hidden from view. These are the build packages and some java files. Right click on the project and choose "Properties" and under "Categories" choose "Java Sources" and click the "Includes/Excludes..." button. See the following image for the filter pattern to use:
NetBeans 8.0.2 Configure Includes & Excludes Dialog Box
  1. If you like, you may exclude all the files in the root of the source files folder so they will not show in the Project Window. See the following image:
NetBeans 8.0.2 Configure Includes & Excludes Dialog Box
  1. To run the project from NetBeans, without having to wait for it to build each time, you can add a new target to Ant by duplicating the existing run target and removing the "depends" attribute. See the following screenshot:
jEdit 5.2.0 build.xml "just-run" Target
  1. You can add a project context menu item for the "just-run" target as well as the "docs-html" target by right clicking on the project and choosing "Properties" and under Categories choose "Build and Run." Then under "Mapping of Custom Contextual Menu Items:" add the 2 entries shown in the following screenshot:  
NetBeans 8.0.2 Project Properties—Build and Run
  1. Now when you right click on the project, there are two new menu items shown. See the following screenshot:
NetBeans 8.0.2—jEdit 5.2.0 Project—New Menu Items
  1. Now you can run jEdit from the new menu item "just-run."
jEdit 5.2.0

Friday, November 14, 2014

New MSYS2 Installers Released

From an email I received from the MSYS2 development team:

Hi all,

We're pleased to announce new installers. Alexey and Martell did much more work to get this into shape than I; many thanks guys. The main focus has been to improve the update experience and remove things from the base system.

Downloads:

http://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20141113.exe/download
http://sourceforge.net/projects/msys2/files/Base/i686/msys2-i686-20141113.exe/download

As MSYS2 is a rolling release distribution, you may already have a lot of these changes (and can of course get them from Pacman). However, we'd appreciate it if people would attempt complete re-installs, reporting any problems they encounter. To do this, please follow the instructions from [1] - copied here:

1. Run your existing MSYS2 installation via msys32_shell.bat 2. Make a list of installed packages:
pacman -Qqe | xargs echo > /c/packages.txt 3. Rename your msys?? folder to msys??.old
4. To save server bandwidth and your time, move your old cached packages directory to the new installation:
In Explorer, remove the empty msys??\var\cache\pacman\pkg folder then replace it with msys??.old\var\cache\pacman\pkg
5. Run the new MSYS2 installation via msys2_shell.bat
6. Re-install your old packages, by entering:
pacman -S --needed --force $(cat /c/packages.txt)

As always, tar.xzs are present for people who don't like installers or who require automation. If you use the 32bit tar.xz version [*] then you should run autorebase.bat before launching the first shell. This is a good time to mention that autorebase.bat is never needed for MSYS2 64bit - one of the important advantages of that version.

MSYS2 changes: pacman.exe and bash.exe are now mostly statically linked (msys-2.0.dll is always dynamic). This means that our update procedure is a lot cleaner now (more work is being done on that). Perl has been removed from the base packages to reduce the download size. Icons have been added to the installers again. The 32bit installer automatically runs autorebase.bat during installation.

Cygwin changes: /etc/passwd and /etc/group are no longer needed, see: https://cygwin.com/ml/cygwin-announce/2014-10/msg00042.html

Best regards,

The MSYS2 development team.

[1] https://sourceforge.net/p/msys2/wiki/MSYS2%20re-installation/
[*] It *only* makes sense to use 32bit MSYS2 if you have 32bit Windows or if you work on PKGBUILDs for MSYS2-packages and need to ensure that the 32bit package can be built.

Friday, September 12, 2014

NetBeans IDE 8.0.1 Released


Neko Bean

NetBean IDE 8.0.1 is the version that NetBeans IDE 8.0 should have been. See the new and noteworthy features here: http://wiki.netbeans.org/NewAndNoteworthyNB801

Download here: https://netbeans.org/downloads/

Tuesday, March 11, 2014

Why Venn Diagrams May Not Be Used To Determine Independence

I took a probability class in college and am currently going through a free MIT probability class on edX.org. Both classes never really showed why you can't always tell if 2 events are independent on a Venn diagram. In the full classroom lecture for the edX class on youtube, the professor explains that independence is not the same thing as disjoint events and then he hints at the fact that you can't use a Venn diagram to tell if 2 events are independent. He then goes on to show that 2 disjoint events are dependent using a Venn diagram. He then blurred through the case when 2 events are joint. He didn't do anything wrong, it was just confusing!

Anyhow, he was right, if the 2 events are disjoint, they are not independent because if one event occurs, then it is impossible for the other event to occur. So the knowledge of one event occurring, necessarily excludes the other event. This makes the 2 events dependent on each other.

To sum this up, in the case of disjoint events, you can tell 2 events are not independent, but if the events have an intersection (joint) they may or may not be independent. Therefore a Venn diagram can't indicate independence and in the case that 2 events are joint, it must either be given in the problem that the events are independent or reasoning and a mathematical test must be used to determine it.

An example of 2 events that are joint, but are independent, is the event that a card chosen from a deck of playing cards is a 4 and the conditional event that the card is a 4 of clubs given that you chose a club. The probability of a card being a 4 is 1/13 and the probability that the card is a 4 given that you chose a club is still 1/13. This comparison against the non-conditional event and the conditional event is the mathematical test to determine if 2 events are independent. The probabilities being the same confirms the 2 events are in fact independent.

Sunday, October 20, 2013

NetBeans IDE 7.4 Released


The wait is finally over! NetBeans IDE 7.4 is finally released. I personally put in ~500 hours over the last 14 weeks testing Java Ant Projects, Java Editor, Options Dialog, and general testing of creating new Java Maven, JavaEE and C/C++ projects. This release definitely has less bugs and is faster than the previous release.

Go get it!

https://netbeans.org/downloads/