Using Webpack’s hot module reloading with an Apache Backend

http://webpack.github.io/docs/webpack-dev-server.html#combining-with-an-existing-server

Even though it doesn’t look like it, everything that you need to know is placed in that blurb.  If you pay attention to the port numbers, the backend is placed on port 9090 and the webpack-dev-server is placed on port 8080.

So the idea is that your backend on port 9090 will be responsible for serving that preliminary html file.  Inside of that html file, the script tag will be pointing toward localhost on port 8080, the webpack-dev-server.

Then you follow the rest of the instructions and it should work just fine.

Incidentally, the root directory was inside of a subdirectory for me, let’s call it “WPExperimental”.  I would navigate to it by going to localhost/WPExperimental/index.html

Also, let’s put all assets under the “asset” folder.

So when writing out the configurations, script src in the html page will point to:

"http://localhost:8080/WPExperimental/asset/bundle.js"

and the output publicPath in the webpack config file will be set to:

"http://localhost:8080/WPExperimental/asset/"

 

index.html is located under the WPExperimental subfolder.  As we mentioned before, pulling the webpage means that we can navigate to in the web browser’s address bar:

http://localhost:9090/WPExperimental/index.html

Notice how I’m using port 9090?  That’s the backend address and we want it to serve the initial template.

And voila.  You set in place a system where you navigate like normal with your backend server, however the javascript stuff are going to be served separately from the webpack_dev_server.

Incidentally, when it’s time to take it to production, I was planning on using Twig, a PHP templater, to mess with the script src link.  Something like

"{{ rootdir }}/asset/bundle.js"

Where rootdir:

equals “http://localhost:8080/WPExperimental/” when DEBUG tokens are enabled.

and equals “/WPExperimental/” when DEBUG tokens are not enabled.

Green Screen when Playing Movies

Since December of 2014, I had a ridiculous problem where some of the movies I was trying to test ended up playing with these kinds of green screens:

NVidia Buggy

 

It’s bright green and it really hurts the eyes.

After some trial and error, I found that rolling back the video driver fixed the error.  So I suppose that I should add that I have an NVidia video card and my media player is Windows Players Classic – Home Cinema (WPC-HC) 32 bit.

Well, that is one solution I suppose.  But I later tried to update the video card driver to a newer one from January 2015.  The same problem once again.

I tried looking for a solution once again.  This time using “Nvidia Driver Green”.  Aside from mentions of a green initiative, I also lucked upon a certain link:

http://www.techpowerup.com/forums/threads/new-nvidia-drivers-344-48.206546/

I found a working solution in this link.  I needed these two posts:

for the green screen issue on newer MPC-HC, I think you should head to Options>Internal Filters>Video Decoder. From There, under “Output Formats” while playing a video, uncheck the “P010” thread, Apply & Exit. Try playing a video again to see whether the green thingy is still there. It’s a rare bug, so it’s no one’s fault anyway. BTW, I usually perform a clean install every time new drivers with new improvements it brings.

Video Decoder Properties

thanks for your helpfull comment. But that alone wasn’t enough to fix my issue.

I’ve had to enable all 3 video filters, and it’s working properly now :)

Player Options

Granted, I didn’t need to enable all 3 video filters (MPEG-2 Video, H264/AVC, VC1), H264/AVC was enough.  So the steps that I took were as follows:

  1. Remove the check from the P010 option in the output formats
  2. Add a check to the H264/AVC Transform Filter.
  3. Video playing back correctly.
  4. Profit

I suppose if you still get the green screen, you may need to add checks to some other transform filters until it finally works.

INNER JOINS with LEFT JOINS

In this scenario, I was attempting to Left Join a table to another table and Inner Joining them to a third table.  I ended up getting no results from the query.

A bit of research found this link:

http://www.sitepoint.com/forums/showthread.php?769412-Combining-Left-and-Inner-Joins

In short, you have to perform the Inner Joins first before you Left Join.

My solution was to Left Join the entire way.  My reason for the Inner Join in the first place, and the reason why I’m unsure of this method was that it seemed like a good way to kill performance.  However, I’m not at the stage where I need to kill time performance tuning the system so I’ll have to ignore it for now.

I’m probably wrong anyway, but it wouldn’t hurt to check when I finally get the time.

Differences between ON AND VS WHERE in SQL for Outer Joins

When joining, I like to use ON + AND a lot.  I heard that this tends to have better performance than running a WHERE query.  And it worked well as long as I stayed with INNER JOINS.  Imagine my surprise when I needed to do a LEFT JOIN while performing a conditional match.  I expected a single row back, but SQL returned every single possible row instead.

After searching around, I found this link:

http://www.codeproject.com/Articles/231132/Difference-between-And-clause-along-with-on-and-Wh

Currently, I’m building up a website, so I can’t begin using Explain to tune.  In the meantime, I’m going to use WHERE to filter the list whenever I have an Outer join.  If this ends up killing performance, I’ll have to find a way to alter the queries later.

PHP Empty Multidimensional Arrays

Discovered today that running empty() on a multidimensional array returns false.

http://forums.phpfreaks.com/topic/183410-checking-if-multidimensional-array-is-empty/

To get around this, I propose using array_filter on the multidimensional array first.  I’m betting this will not work for an array within an array within an array, but it seems to work fine for an array within an array.

So:

empty( array_filter( $multidim_array ) )

Windows Automatically Lowers Volume

I had this aggravating problem where turning on or off monitors suddenly caused the sound to dim.

I’m running Windows 7, but this seemed to be the solution to my problem:

http://superuser.com/questions/504004/windows-8-turns-program-sound-volume-down-randomly?lq=1

In short, windows was lowering the volume because it thought that communication was taking place.  If I had to take a guess, it’s because Windows 8 aims to be an O/S on all devices to the point that features commonly found on phones are being ported to the desktop.  With annoying effects.

Creating Local Git Repositories with Sourcetree

Storing a repository locally on your hard drive sort of defeats the purpose behind Git’s design…it’s not on a remote server with timely backups, and you’re basically the only one who can access and maintain it.

That said, it is a viable solution if you happen to like using Git and you have the following reasons for doing it:

  • You’re using Windows
  • You want to version control your own code
  • You want to keep your code in your hands and not some server several hundred miles away.
  • You don’t have a convenient local area network computer to store the repository.

Surprisingly, it isn’t as difficult as most solutions make it out to be.  In fact, you do not need to run your own Git server.  All you need is a git client.  Then, using the client, you create two repositories instead of one.  And then have one repository point to the other as the remote.

You have to deal with one problem however, pushing will probably throw an error.  Git will refuse to push because the remote has a checked out branch.

http://stackoverflow.com/questions/11117823/git-push-error-refusing-to-update-checked-out-branch

There are three different solutions:

  1. Create a bare repository
  2. Create and check out a dummy branch on the remote repository
  3. Edit the configuration files to ignore this check

I’m going to cover two of them since the third one strikes me as interesting, but bad practice.  The first solution cannot be done using Sourcetree alone.  Creating a bare repository:

https://answers.atlassian.com/questions/172509/how-do-i-create-clone-a-bare-repository-in-sourcetree

What is a bare repository?

Bare repository is the one that has no working tree. It means its whole contents is what you have in.git directory.

You can only commit to bare repository by pushing to it from your local clone. It has no working tree, so it has no files modified, no changes.

To have central repository the only way it is to have a bare repository.

I included the above quote to basically say that a bare .git repository is just going to have a .git folder with stuff inside.  Nothing else will be in that directory, so if you do have source code in that directory, do not be afraid if they are not being updated whenever you push.

In Git you should only use a “bare” repository to clone and pull from, and push to. It doesn’t have a checked out tree, so it just does what the “server” notionally does in a centralized VCS – records commits, branches, etc when you push to it, and gives you the latest versions when you clone or pull from it.

I suppose I should also say that I’m throwing all the above links because I saw a stack overflow comment about how online repositories like GitHub are basically bare .git repositories, but I lost the link. Or maybe I didn’t…

There are two types of repositories: bare and non-bare

Bare repositories do not have a working copy and you can push to them. Those are the types of repositories you get in Github! If you want to create a bare repository, you can use

git init --bare

So, in short, you can’t push to a non-bare repository (Edit: Well, you can’t push to the currently checked out branch of a repository. With a bare repository, you can push to any branch since none are checked out. Although possible, pushing to non-bare repositories is not common). What you can do, is to fetch and merge from the other repository. This is how the pull request that you can see in Github works. You ask them to pull from you, and you don’t force-push into them.

But, as said before, you cannot create a remote repository using sourcetree alone.  Converting a remote repository to a bare repository can be done using the following method:

You can simply convert your remote repository to bare repository (there is no working copy in the bare repository – the folder contains only the actual repository data).

Execute the following command in your remote repository folder:

git config --bool core.bare true

Then delete all the files except .git in that folder. And then you will be able to perform git push to the remote repository without any errors.

As said twice before, you can’t use Sourcetree to do the above.  However, you can download and use Git from the command line to pull it off:

http://git-scm.com

Which leads to our second solution…how can you push to the local (remote) repository using sourcetree?

The answer is to go to the second repository and create a dummy branch.  Then check out the dummy branch.  Now you can use the first repository to push to the second repository.

Remind me that I need to add how-to create the repositories later.

 

Preventing Post Resubmission

http://stackoverflow.com/questions/11377259/form-is-resubmitted-when-the-back-button-is-pressed

The above link had some good links inside.  I’ve attached them below:

http://stackoverflow.com/questions/3923904/preventing-form-resubmission

http://stackoverflow.com/questions/660329/prevent-back-button-from-showing-post-confirmation-alert

 

The following link contains info on how to do it server side.

http://bjw.co.nz/developer/general/75-how-to-prevent-form-resubmission