Tuesday, December 24, 2013

How to view the source after a webpage has been loaded with AJAX


  1. Use Chrome.
  2. Bring up the developer tools by right clicking anywhere on the page, and selecting "Inspect Element.
  3. Click on the "Elements" tab
  4. Right click on the <html...> tag, and select "Copy as HTML"
  5. Paste the clipboard into your favorite text editor.

Tuesday, December 17, 2013

How to save an encrypted iPhone voice mail as an mp3 on Windows

My daughter left me her voice mail today.  She had her mom's phone on the way home, called me, and cried for 72.78 seconds.  I had to save this voice mail, so this is how I did it:

  1. Backup your iphone using iTunes
  2. Download Backuptrans itunes Backup Extractor: http://www.backuptrans.com/itunes-backup-extractor.html
  3. This will allow you to retrieve up to 3 voice mails
  4. To convert the .amr file to .mp3, use http://audio.online-convert.com/convert-to-mp3

Thursday, November 21, 2013

How to get gzip working for Jetty 8 and Solr

If you're getting the following error message in the solr.log file:

java.lang.ClassNotFoundException: org.eclipse.jetty.servlets.GzipFilter

Try doing the following:

Edit /opt/solr/solr-webapp/webapp/WEB-INF/web.xml and put the following in it:


<web-app ... >


<filter>
      <filter-name>GzipFilter</filter-name>
      <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
      <init-param>
        <param-name>mimeTypes</param-name>  
        <param-value>text/html,text/plain,text/xml,application/xhtml+xml,application/xml,text/css,application/javascript,image/svg+xml,application/json,application/xml; charset=UTF-8</param-value>
      </init-param>
    </filter>
    <filter-mapping>
      <filter-name>GzipFilter</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

If you don't have a jetty-servlets*.jar file, then download it from http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets and put it in /opt/solr/lib

Restart jetty:

sudo /sbin/service jetty restart

If solr doesn't start up, check the /opt/solr/logs/solr.log file.

Tuesday, November 19, 2013

How do I show PHP errors on a webpage?

In your /etc/php.ini file, add the following:

error_reporting(E_ALL);
ini_set('display_errors', 'on');

Friday, November 8, 2013

How to require password authentication for Apache Solr 4 and Jetty

Some of the documentation in the Solr wiki is outdated, so here's what worked for me.  In the following files, you can change the highlighted fields.

Edit /opt/solr/etc/jetty.xml and add the following:

<Configure>

    <Call name="addBean">
      <Arg>
        <New class="org.eclipse.jetty.security.HashLoginService">
          <Set name="name">Test Realm</Set>
          <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
          <Set name="refreshInterval">0</Set>
        </New>
      </Arg>
    </Call>

...

</Configure>

Edit  /opt/solr/solr-webapp/webapp/WEB-INF/web.xml and add the following:

<web-app>
...
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Solr authenticated application</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>core1-role</role-name>
    </auth-constraint>
  </security-constraint>

  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Test Realm</realm-name>

  </login-config>

...
</web-app>

Create a file in /opt/solr/etc/realm.properties and put the following in it:

admin: yourPasswordHere,core1-role

You can change "admin" to whatever username you want.

For the password, you can either use the literal password, or use an OBF/MD5/CRYPT hash.  To create a hash, you can do the following:

cd /opt/solr
java -cp /lib/jetty-util-8.1.10.v20130312.jar org.eclipse.jetty.util.security.Password admin yourPasswordHere

The above utility will print out the hash to the screen, and you can chose either the OBF, MD5, or CRYPT line.  Make sure that you copy the entire line, including the "OBF:..." part.  Copy this line to the /opt/solr/etc/realm.properties file; the result will look something like this:

admin: OBF:1x1v1xmk1w9b1pyh1oq31uum1xtv1zej1zer1xtn1uvk1or71pw51w8f1xmq1x0r
,core1-role

The above is all in one line.  No line break.  Make sure you put the comma before the "core1-role".

After you've changed everything, restart the solr server.  If you're using Fedora, do this:

sudo /sbin/service jetty.sh restart

Then open up your web browser to http://localhost:8983/solr/#/collection1/query and the web browser should ask you for a password.  Enter admin for the user name and yourPasswordHere for the password.

Hint: if you get an error on the Solr admin webpage, you can check the log for warning messages.  The log file is here: /opt/solr/logs/solr.log

More info:



Monday, November 4, 2013

Ruby, yaml, and gem in Fedora Linux

If you're trying to use gem to install something, and you're getting the following error message:

It seems your ruby installation is missing psych (for YAML output)....

You could try to install libyaml like this:

yum install libyaml

If that still doesn't work, it might be because the libyaml library is not new enough.  If that's the case, install libyaml from source from here:

http://pyyaml.org/download/libyaml/

Then, uninstall ruby, and then re-install ruby.  Hopefully you'll have success after that.

Friday, October 18, 2013

S&P 500 during certain presidencies

I don't pretend to claim a causal relationship, but since we're at an all time high, I felt like looking up the facts:

Clinton: +210.69% http://finance.yahoo.com/echarts?s=%5EGSPC+Interactive#symbol=%5Egspc;range=19930118,20010119;compare=;indicator=volume;charttype=area;crosshair=on;ohlcvalues=0;logscale=off;source=undefined;

Bush 43: -38.60% http://finance.yahoo.com/echarts?s=%5EGSPC+Interactive#symbol=%5Egspc;range=20010119,20090120;compare=;indicator=volume;charttype=area;crosshair=on;ohlcvalues=0;logscale=off;source=undefined;

Obama: +108.32% http://finance.yahoo.com/echarts?s=%5EGSPC+Interactive#symbol=%5Egspc;range=20090120,20131018;compare=;indicator=volume;charttype=area;crosshair=on;ohlcvalues=0;logscale=off;source=undefined;

To be fair, Reagan and Bush 41: +234.88% http://finance.yahoo.com/echarts?s=%5EGSPC+Interactive#symbol=%5Egspc;range=19810119,19930120;compare=;indicator=volume;charttype=area;crosshair=on;ohlcvalues=0;logscale=off;source=undefined;

Thursday, October 17, 2013

Resolve "Can't right click on message in Outlook 2003" issue

For a long time, I haven't been able to right click on an email in Outlook 2003 (e.g. to flag it).  This is how to resolve it:

1) Exit Outlook and other Office apps

2) Go to C:\users\username\AppData\Local\Microsoft\FORMS

3) Delete the FRMCACHE.DAT file

4) Restart Outlook

Wednesday, September 25, 2013

How to Convert MS Access Database to MySQL

MySQL Workbench (versions 5 and 6) contain a Migration Toolkit to convert external databases to MySQL, but Microsoft Access isn't an option.  However, it used to be an option in the predecessor tool: MySQL GUI Tools.  Fortunately, you can download an archived installer for MySQL GUI Tools here:

http://dev.mysql.com/downloads/gui-tools/5.0.html

With that, if you install MySQL GUI Tools (and install a 32-bit version of the Java JRE 6), if you start the MySQL Migration Toolkit, there is an option to convert from an Microsoft Access database.  I chose all of the default settings (except I asked for .sql scripts to be saved), and it converted fine.

Thursday, September 12, 2013

How to change the default OS in grub on Fedora 16, Fedora 17, Fedora 18, and Fedora 19

See https://ask.fedoraproject.org/question/8885/how-can-i-change-default-operating-system-in-start-up-boot-menu/

Essentially, you will want to change the /etc/default/grub file and then perform the following:

grub2-mkconfig -o /boot/grub2/grub.cfg

Tuesday, September 10, 2013

Why can't I click on the confirm box when encrypting a partition in the Fedora 18 or Fedora 19 installer (anaconda)?

If you are having trouble clicking or switching to the "confirm" box when typing in your passcode/password in the Fedora 18 or Fedora 19 installer, here's what you can do:


  1. Ensure that your passcode is strong enough. Make sure that the red stop sign disappears.
  2. Press "Tab" on the keyboard to switch to the "confirm" box.
That's it.

Saturday, August 24, 2013

How to log every query in MySQL on Fedora

In /etc/my.cnf, in the [mysqld] section, add the following 2 lines:

general_log=1
general_log_file=/var/log/mysql.log

Then:

sudo su
touch /var/log/mysql.log
chown mysql:mysql /var/log/mysql.log

Restart mysqld:

sudo /sbin/service mysqld restart

Note that the "log" variable in my.cnf is now deprecated, and doesn't log files in Fedora 14.


Friday, August 23, 2013

How to Install MongoDB on Fedora

If you are using the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/ they say to create a file called /etc/yum.repos.d/10gen.repo - but if you try that, you may be getting the following error when trying to start the mongod service.

It turns out that mongodb is built into fedora (via yum), so you don't need to add the 10gen.repo file.  Here's how to install mongodb on Fedora:

1) Uninstall mongodb:

yum erase mongodb
yum erase mongo-10gen

2) Remove the 10gen.repo file

rm /etc/yum.repos.d/10gen.repo

3) Install mongodb via default yum

yum install mongodb mongodb-server

4) Start monogodb service

/sbin/service mongod start


Tuesday, August 20, 2013

Friday, August 16, 2013

Why won't MySQL Workbench let me add a Foreign Key relationship?

You might be unable to check the desired foreign column box in MySQL Workbench.

If you are trying to add the foreign key on the command line, then you may also be getting "a can't create table 150 alter table" and Error Code 1005 error.

Make sure that you have the table and column names correct.

Also make sure that the two columns are EXACTLY the same type.  Check for int(10) vs int(11) and int(10) vs int (10) unsigned.  They have to be EXACTLY the same type.  MySQL Workbench may not show or let you change int(10) to int(10) unsigned, but you can check the exact column type using "show create table", and you can change it on the command line like this:

ALTER TABLE TableName CHANGE columnName columnName  int(10) unsigned DEFAULT NULL

After this, you should be able to check the desired box in MySQL Workbench.

Also, make sure that both tables are using InnoDB

Also see: http://stackoverflow.com/questions/9018584/error-code-1005-cant-create-table-errno-150

Monday, August 12, 2013

How to recover found.000 folder that is locked

On Windows 7, if chkdsk recovers a found.000 folder, and you can't access it, and if changing ownership to you doesn't work, try this simple trick:

Copy the folder to another area.

Then try to access the copy of that folder.

For some reason, it works for me.

Friday, July 26, 2013

How to disable Java Updater Tray Icon in Windows

If you ask Java to disable the tray icon, sometimes it won't respect your wishes.  The issue is that the Administrator needs to disable it.  This what you do:

1) Start the command prompt as the Administrator
2) cd \Program Files\Java\jre6\bin
3) javacpl
4) Go to the Advanced Tab
5) Expand Miscellaneous
6) Uncheck the Place Java icon in system tracy
7) Right click the Java icon, and click on Cancel
8) Under Advanced | JRE Auto-Download, switch it to Never Auto-Download

Thursday, July 4, 2013

Why does Windows 7 reboot itself every 2 minutes?

I ran into this issue: I had installed the 320.49-desktop-win8-win7-winvista-64bit-english-whql.exe NVidia GeForce driver.  This forced me to install some type of .NET 4 (extra?) runtime environment.  The next time I booted my computer, Windows 7 would automatically reboot itself after about 2-3 minutes.  If I were in safe mode, it didn't reboot.  This is how I solved it:

  1. Booted Windows 7 in safe mode (press F8 when booting)
  2. Installed an old NVidia driver, such as 314.07-desktop-win8-win7-winvista-64bit-english-whql.exe
  3. Reboot Windows in normal mode
  4. Now you have to be real quick before your machine reboots: uninstall the .NET 4 runtime environment that had just been installed.  The uninstaller will ask you to reboot your machine.  Reboot it into normal mode.
  5. If all goes well, your system will be back to normal!

You can also try reading the logs in the Event Viewer for some hints.

Similar symptom, different solution: http://social.technet.microsoft.com/Forums/windows/en-US/d7379f4d-9337-4800-9c8b-582fd0c439a7/windows-7-pro-keep-restarting-on-itself-will-not-last-longer-than-2-minutes-but-safemode-works

Ditto: http://www.tomshardware.com/answers/id-1672386/computer-rebooting-pretty-stumped.html

Wednesday, July 3, 2013

How to get viewvc working with Apache httpd and Fedora and subversion (svn)


  1. Get subversion working with httpd first. (See http://muddyazian.blogspot.com/2013/05/how-to-start-subversion-repository-over.html)
  2. yum install viewvc viewvc-httpd
  3. Edit /etc/viewvc/viewvc.conf and modify the svn_roots and root_parents options.
  4. Edit /etc/httpd/conf/httpd.conf and add in the following:

    <Directory /usr/lib/python2.7/site-packages/viewvc/bin/mod_python>
      Order allow,deny
      Allow from all
      AuthType Basic
      AuthName "Subversion repositories"
      AuthUserFile /etc/svn-auth-users
      Require valid-user
    </Directory>

    <Directory /usr/share/viewvc/templates/docroot>
      Order allow,deny
      Allow from all
    </Directory>

    ...

    Alias /viewvc-static "/usr/share/viewvc/templates/docroot/images"

    ...

    ScriptAlias /viewvc /usr/lib/python2.7/site-packages/viewvc/bin/cgi/viewvc.cgi
    ScriptAlias /query /usr/lib/python2.7/site-packages/viewvc/bin/cgi/query.cgi

  5. Restart the web server: /sbin/service httpd restart
  6. Go to http://localhost/viewvc
  7. If you haven't already done so, create the /etc/svn-auth-users file:

    htpasswd -cm /etc/svn-auth-users firstUsername
    New password:
    Re-type new password:
    Adding password for user firstUsername
You can test things out (sanity check) like this:

/usr/lib/python2.7/site-packages/viewvc/bin/standalone.py -r /path/to/svn/repository/location

Then in firefox, go to http://localhost:49152/viewvc

Wednesday, May 29, 2013

Change Font Size of Tabs in Eclipse Juno on Fedora

Edit ECLIPSE_HOME/plugins/org.eclipse.platform_4.2.2.v201302041200/css/e4_default_gtk.css

Change  the following


.MPartStack {
font-size: 6;

How to set up a email mailer post commit script with subversion on Fedora.

From http://stackoverflow.com/questions/501692/easiest-best-way-to-set-up-svn-commit-emails, the easiest way is to use the existing .py mailer script.

_____________

On Fedora 15, do the following:

yum install subversion-python

_____________

In your subversion repository:

cd hooks

cp post-commit post-commit.tmpl

Change

mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

to

/usr/share/doc/subversion-1.6.18/tools/hook-scripts/mailer/mailer.py commit "$REPOS" "$REV" /etc/mailer.conf

_____________

After that, do the following to setup the mailer.conf file:

cp /usr/share/doc/subversion-1.6.18/tools/hook-scripts/mailer/tests/mailer.conf /etc/mailer.conf

Edit the mailer.conf and:

uncomment  mail_command = /usr/sbin/sendmail

add in commit_subject_prefix

add in propchange_subject_prefix

add in lock_subject_prefix

add in unlock_subject_prefix

Add in from_addr

Add in to_addr

_____________

Test it out by committing a test revision.

Tuesday, May 21, 2013

Using Unity over proxy with Windows 7

1) Go to Control Panel\All Control Panel Items\System and Go to "Advanced system settings".

2) Under the Advanced Tab, go to Environment Variables, and add two variables: HTTP_proxy and HTTPS_proxy.  Set it to your proxy, such as http://myproxy.domain.com:80 and restart Unity.

3) If you get certificate errors, you can manually activate, using the steps found here: http://answers.unity3d.com/questions/358967/peer-certificate-cannot-be-authenticated-with-know.html

Also from http://blog.gfx47.com/2011/03/08/unity3d-httphttps-proxy-problem-solved-o/

Tuesday, April 9, 2013

Create a tracking branch off of a remote branch in git

git branch --track branchName origin/branchName
git checkout branchName

Wednesday, March 27, 2013

Resolve "Agent admitted failure to sign using the key."

You might be getting the following error message, perhaps when either using ssh or git:


Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Solve this by this simple fix:

ssh-add

What may have happened, is that you changed your ssh key, and something got confused.

Thursday, February 14, 2013

How to format JSON on the command line

Also known as pretty print.

echo myFile.json | python -mjson.tool

Tuesday, February 12, 2013

Why do I get SplFileInfo::getMTime()... errors in symfony2?

The error, in the browser, might look like this:

SplFileInfo::getMTime() [<a href='splfileinfo.getmtime'>splfileinfo.getmtime</a>]: stat failed for /var/www/html/Symfony/src/Srb/AnthonyBundle/Controller/.#DefaultController.php

If you are using emacs, make sure you save off all files.  If you don't, you might have a # file around, and symfony gets confused.

Install symfony2 and doctrine using composer

1A) Download composer, which will download the composer.phar file which can be kept anywhere:

cd /path/to/composer/install/dir
curl -s https://getcomposer.org/installer | php

1B) Install symfony:

cd /path/to/composer/install/dir
php composer.phar create-project symfony/framework-standard-edition /path/to/webroot/Symfony 2.1.x-dev

2) Check the configuration

Go to http://localhost/Symfony/web/config.php

3) Configure the database

Edit the /path/to/webroot/Symfony/app/config/parameters.yml file

4A) If you already have the database table created, make sure that the primary key is named id.

4B) If you already have the database table created, you can skip to creating an entity class:

php app/console doctrine:generate:entity --entity "MySpecificBundle:Things" --fields="id:int(11) price:float"

5) Edit the src/.../Controller/DefaultController.php file to do something interesting with the database table.

For example:

$row = $this->getDoctrine()
  ->getRepository('MySpecificBundle:Things')
  ->find($name);

if (!$row)
  {
  throw $this->createNotFoundException('No row found for id: '.$name);
  }

$otherVariable = $row->getOtherVariable();

return array('name' => $otherVaraible);

6) Open your browser to http://localhost/Symfony/web/app_dev.php/hello/1 to view the row

7) To create a CRUD scaffold, perform the following command:

php app/console doctrine:generate:crud --entity="MySpecificBundle:Things"

Then open your browser to http://localhost/Symfony/web/app_dev.php/things


Friday, February 8, 2013

Install Symfony2 and propel using composer

1A) Download composer, which will download the composer.phar file which can be kept anywhere:

cd /path/to/composer/install/dir
curl -s https://getcomposer.org/installer | php

1B) Install symfony:

cd /path/to/composer/install/dir
php composer.phar create-project symfony/framework-standard-edition /path/to/webroot/Symfony 2.1.x-dev

_____________________

2) To optionally install propel:

2A) Configure composer.json file

  cd /path/to/webroot/Symfony

  Open /path/to/webroot/Symfony/composer.json in a text editor
  Add in the following line:


 "require": {
        ... ,
        "propel/propel-bundle": "1.1.*"
    },

2B) Download and install propel:

cd /path/to/webroot/Symfony
php /path/to/composer/install/dir/composer.phar update

After this step, you'll need to manually register the bundle in the AppKernel.php file.  See the following page for how to do that: http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#configuration (Search for "The second step is to register this bundle in the AppKernel class:") (Note that I had to add the first configuration on that page, even though I was using Composer")

After that, you'll need to "configure the bundle": http://propelorm.org/cookbook/symfony2/working-with-symfony2.html#configuration Note: I had to comment out or delete the doctrine: block, otherwise symfony would get confused and thought I was using doctrine.

Wednesday, February 6, 2013

How to get HP Color LaserJet 2605dn to print color

I've had a problem getting my HP Color LaserJet 2605dn printer to print color on my Windows 7 64-bit machine, but it's working now.  I had to use the Universal Print Driver (UPD), and in the Control Panel (Control Panel\All Control Panel Items\Devices and Printers), right click on the printer, go to Printer Properties > Device Settings > Device Type (way at the bottom), and change "Auto Detect" to "Color".  You should now be able to print color.