Sunday, March 16, 2014

Saturday, November 30, 2013

What is the ii/IV - V/IV - IV progression


ii/IV is read as "two of four" which is Gm7 in the key of C.

V/IV is read as "five of four" which is C7 in the key of C.

and IV is F in the key of C.

You can find an example of this by Greg Howlett on thins link.




  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists

Sunday, November 10, 2013

How to install Ruby on Rails offline in Windows 7 and use WEBrick as web server

When online
  1. Download railsinstaller-2.2.1.exe from http://railsinstaller.org/
  2. Download uglifier-2.2.1.gem from http://rubygems.org/gems/uglifier

When offline (on another computer)
  1. Execute railsinstaller-2.2.1.exe
  2. Open command window
  3. Using the command window, navigate to the directory where uglifier-2.2.1.gem is saved
                                 cd <path where uglifier-2.2.1.gem is saved>
  1. Type the following command:
                                gem install --local uglifier-2.2.1.gem
  1. Create your Rails site with the following command:
                                rails new <name of your site>
  1. Using the command window, navigate to the directory of your site:
                                cd <path of your site>
  1. While inside your site's directory, run the web server (WEBrick):
                                rails server
  1. Open your web browser to view your site: http://localhost:3000/

Tuesday, June 11, 2013

From Nand to Tetris - My Solutions to the Projects


I have created a repository to contain my solutions to the projects of the course "From Nand to Tetris"
(You can also get the reading materials and projec files at http://www.cs.huji.ac.il/course/2002/nand2tet/projects.html)

Here is the repository of my solutions: https://github.com/jboyflaga/Nand2Tetris
(Some of my solutions are not very good even though the output is still correct. Be sure to also look at other people's solutions for reference.)

UPDATE (November 17, 2013): I deleted the GitHub repository of my solutions to the Nand2Tetris projects 1 to 8 because someone who is teaching it (Alex Lipov) requested for it to be removed because it violated the course terms (http://www.nand2tetris.org/terms.php).

If you want to know how to start the course just read the whole Chapter 1 available in http://www.nand2tetris.org/course.php or http://www.cs.huji.ac.il/course/2002/nand2tet/projects/proj1.html. You will know what to do especially after you read the last part of chapter 1.

Enjoy!!!

Friday, May 31, 2013

From Nand to Tetris - Project 4 (Fill)

This is my solution to the exercises (Fill) in Project 4 of the free course From Nand to Tetris
Other Links:
http://www.cs.huji.ac.il/course/2002/nand2tet/projects.html
// Runs an infinite loop that listens to the keyboard input. 
// When a key is pressed (any key), the program blackens the screen,
// i.e. writes "black" in every pixel. When no key is pressed, the
// program clears the screen, i.e. writes "white" in every pixel.

// (RESET_SCREEN_COUNTER)
 // @SCREEN
 // D=A
 // @counter
 // M=D    // counter = SCREEN

(LISTEN_FOR_NO_KEY_PRESS)
 // reset screen counter
 @SCREEN
 D=A
 @counter
 M=D
 
 // if KBD == 0 jump to CLEAR_SCREEN
 @KBD
 D=M
 @CLEAR_SCREEN
 D;JEQ

 // loop (keep on checking if KBD == 0
 @LISTEN_FOR_NO_KEY_PRESS
 0;JEQ

(LISTEN_FOR_KEY_PRESS)
 // reset screen counter
 @SCREEN
 D=A
 @counter
 M=D
 
 // if KBD > 0 jump to BLACKEN_SCREEN
 @KBD
 D=M
 @BLACKEN_SCREEN
 D;JGT
 
 // loop (keep on checking if KBD > 0
 @LISTEN_FOR_KEY_PRESS
 0;JEQ
 
(BLACKEN_SCREEN) 
 // blacken 16-bit memory location
 @counter
 A=M    // A = counter
 M=-1   // blacken current memory location
  
 // if KBD == 0 jump to LISTEN_FOR_NO_KEY_PRESS (to reset counter)
 @KBD
 D=M
 @LISTEN_FOR_NO_KEY_PRESS
 D;JEQ

 // increment counter
 @counter
 M=M+1
 
 // check if you have reached memory location 24575 (the final address for the screen)
 D=M
 @24575
 D=A-D
 @LISTEN_FOR_NO_KEY_PRESS
 D;JLT   // goto LISTEN_FOR_NO_KEY_PRESS if counter > 24575
 
 // loop BLACKEN_SCREEN if you have NOT reached memory location 24575
 @BLACKEN_SCREEN
 0;JEQ 

(CLEAR_SCREEN)
 // clear 16-bit memory location
 @counter
 A=M    // A = counter
 M=0    // clear current memory location
 
 // if KBD > 0 jump to LISTEN_FOR_KEY_PRESS (to reset counter)
 @KBD
 D=M
 @LISTEN_FOR_KEY_PRESS
 D;JGT
 
 // increment counter
 @counter
 M=M+1
 
 // check if you have reached memory location 24575 (the final address for the screen)
 D=M
 @24575
 D=A-D
 @LISTEN_FOR_KEY_PRESS
 D;JLT   // goto LISTEN_FOR_KEY_PRESS if counter > 24575
 
 // loop CLEAR_SCREEN if you have NOT reached memory location 24575
 @CLEAR_SCREEN
 0;JEQ

Friday, May 3, 2013

The Humans Project - using the HotTowel SPA template


This is a very very simple app I created to practice developing a SPA (Single Page App).

I used the HotTowel SPA template created by John Papa.
To learn more about HotTowel go to http://www.johnpapa.net/hottowel/.

HotTowel uses the Durandal SPA framework
To know more about Durandal go to the folowing pages:
http://durandaljs.com/pages/get-started
http://durandaljs.com/pages/videos/

The project is available on github.
 
(This is not yet finished)
(And pardon the look of the pages... I'm not a very good designer...)





  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists

Thursday, May 2, 2013

Using X509Certificate2UI.SelectFromCollection() with WPF and MVVM

I had a task which involves making the user select a certificate from the store.
(We are using .NET)

I used WPF and the MVVM pattern for the UI; and I used the MVVM Light Toolkit to help with MVVM development.

I used the X509Certificate2UI.SelectFromCollection() method to show a dialog for the user to select a certificate (X509Certificate2UI is in the System.Security.Cryptography.X509Certificates namespace, System.Security.dll assembly)
X509CertificateCollection certificateCollection = X509Certificate2UI.SelectFromCollection(
                    store.Certificates, "Caption", "Message",
                    X509SelectionFlag.SingleSelection);


My problem was the dialog that X509Certificate2UI.SelectFromCollection() is not modal and it does not close when I close the main window.

The solution was to use the overloaded method of X509Certificate2UI.SelectFromCollection() which accepts a handle to the parent window.
WindowInteropHelper windowHwnd =new WindowInteropHelper(this); 
IntPtr hWnd = windowHwnd.Handle;
X509CertificateCollection certificateCollection = X509Certificate2UI.SelectFromCollection(
                    store.Certificates, "Caption", "Message",
                    X509SelectionFlag.SingleSelection, hWnd);

[To know more about Win32 Handles go to "Win32 Handle (HWND) & WPF Objects - A Note" - http://www.abhisheksur.com/2010/12/win32-handle-hwnd-wpf-objects-note.html ...]

But there was another problem: Because I was using MVVM with WPF I have to put this logic inside my ViewModel. But ViewModel does not have direct acces to the Window element!

The solution was to pass the Window object as parameter to a Command object as shown below

[The View - XAML]

<Window ...  Name="TheMainWindow"
   DataContext="{Binding Main, Source={StaticResource Locator}}">
  <Button Command="{Binding SelectCertificateCommand}" CommandParameter="{Binding ElementName=TheMainWindow}" Content="Select Certificate From the Store" />
 </Window>

[The ViewModel]
[ViewModelBase and RelayCommand are from the MVVM Light Toolkit]
    public class MainViewModel : ViewModelBase
    {
        private X509Certificate2 _selectedCertificate;

        public ICommand SelectCertificateCommand { get; private set; }

        public MainViewModel()
        {
            this.SelectCertificateCommand = new RelayCommand(
                (window) =>
                {
                    X509Certificate2 cert = PickCertificate(StoreLocation.CurrentUser, StoreName.My, window);
                    if (cert != null)
                    {
                        this.Certificate = cert;
                    }
                });
        }

        public X509Certificate2 Certificate
        {
            get { return _selectedCertificate; }
            set
            {
                if (_selectedCertificate == value) { return; }
                _selectedCertificate = value;
                RaisePropertyChanged(() => Certificate);
            }
        }

        private static X509Certificate2 PickCertificate(StoreLocation location, StoreName name, Window window)
        {
            X509Store store = new X509Store(name, location);
            try
            {
                store.Open(OpenFlags.ReadOnly);

                // pick a certificate from the store 
                X509Certificate2 certificate = null;
                X509CertificateCollection certificateCollection = X509Certificate2UI.SelectFromCollection(
                    store.Certificates, "Select a certificate", "Select a certificate",
                    X509SelectionFlag.SingleSelection, new WindowInteropHelper(window).Handle);
                if (certificateCollection.Count > 0)
                {
                    certificate = (X509Certificate2)certificateCollection[0];
                }

                return certificate;
            }
            finally
            {
                store.Close();
            }
        }
    }





  
Free Lessons for Chruch Pianists:
Free lessons, tips and downloads for church pianists

DVD Courses (Reharmonization, Play by Ear!, Arranging, Accompanying, Theory for Church Pianists, etc.):
Over 30 hours of DVD instruction for church pianists