Friday, October 25, 2019

Get The Password for a Quickbooks QBW File

A C Program to Recover Your Quickbooks Pro 5.0 File


Sure it's old, but I will share it with the world. It works with Quickbooks 5.0


/* -*-C-*-
****************************************************************************
***
*
* File:         get-qb-pw.c
* RCS:          $Id: $
* Description:  get the "quick books pro" password
* Author:       Eric Blossom
* Created:      Tue Aug 18 14:09:30 1998
* Modified:     Tue Aug 18 17:39:22 1998 (eric) eb@starium.com
* Language:     C
* Package:      N/A
* Status:       Experimental (Do Not Distribute)
*
****************************************************************************
***
*/

/* * This has been tested only on QuickBooks Pro version 5.0
 */

#include <stdio.h>

main (int argc, char **argv)
{
  FILE          *fp;
  int           i;
  unsigned char raw[10];

  if (argc != 2){
    fprintf (stderr, "usage: get-qb-pw filename\n");
    exit (1);
  }

  if ((fp = fopen (argv[1], "rb")) == 0){
    perror (argv[0]);
    exit (1);
  }


  if (fseek (fp, 7635, SEEK_SET) != 0){
    perror ("fseek failed");
    exit (1);
  }

  if (fread (raw, 1, 10, fp) != 10){
    perror ("fread failed");
    exit (1);
  }

  for (i = 9; i >= 0; i--){
    int         t;

    if (raw[i] == 0)
      continue;

    t = ((raw[i] & 0xf) << 4) | ((raw[i] >> 4)  & 0xf); /* swap nybbles */
    putchar (-t + 255);
  }

  putchar ('\n');
}

How to Install OpenVPN

How to Install Open VPN on Ubuntu

See this great blog entry.  https://blog.ssdnodes.com/blog/tutorial-installing-openvpn-on-ubuntu-16-04/


Tuesday, October 8, 2019

A MySQL Wrapper for mysqli - old skool mysql

A Wrapper for mysqli to Enable Old Skool Mysql


Get this cool mysql wrapper from github to retrofit your old skool mysql / php code to work on php7 where mysql has been replaced by mysqli.

logon to your webserver using SSH, and then on your command line shell, in your webroot directory, do this:

mkdir ext
cd ext
git clone https://github.com/e-sites/php-mysql-mysqli-wrapper.git

then copy it to ./lib
in your php code:

....
include("./lib/mysql.php");
include("./common/lib.php");
include("./lib/class.db.php");
include("./common/config.php");



Monday, October 7, 2019

How to Restore Legacy mysql to php7 - when you really hate mysqli

How to put MySQL functions back into PHP 7

PHP 7 will go “release candidate” on August 20th 2015 which is very exciting because it will instantly be twice as fast as PHP 5.6 (and all previous versions). PHP7 gives HHVM a run for the money and takes 5 minutes to compile instead of hours for HHVM.
But there is a catch – if you have any legacy code that uses the mysql_* functions, they will stop working entirely in PHP 7. Not just a warning, not just deprecated, but gone, fatal.
However, it is easy to get them back without using a wrapper or modifying your code…
I wouldn’t plan on using this solution far past 2016 but it will keep your legacy code running in the meanwhile.
Simply compile the mysql function as a php pecl extension and add one line to your php.ini
First get the mysql extension source which was removed in March:
https://github.com/php/php-src/tree/PRE_PHP7_EREG_MYSQL_REMOVALS/ext/mysql
Either:
1
2
cd ext/
or
or
http://pecl.php.net/package/mysql
(same code, same timestamp, now static and likely will never be updated again)
Then compile the code on your server:
1
2
3
4
phpize
./configure
make
make install
The “make install” should announce where it is copying mysql.so – copy that path. It will likely be /usr/local/lib/php/extensions/no-debug-non-zts-20151012/ for PHP 7 but it could vary depending on your server setup.
Then edit your php.ini
Somewhere either in the “Extensions” section or “MySQL” section, simply add this line:
1
extension = /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mysql.so
(change path if needed)
Restart PHP and mysql_* functions should now be working again. Check your php error log if you have any problems (should check it periodically anyway). You will also see the MySQL section back in your phpinfo page.

Alternately, compile the mysql support into the PHP binary

It is also possible to compile PHP with the mysql extension built right in, so you don’t need to change the php.ini file – follow these instructions:
Basically you put the mysql source under ext/mysql then clear out any existing configure in the php source root and force buildconf to make a new configure. Then compile php including –with-mysqlon the ./configure command line.
Note that PHP 7 deprecates several other functions and is more strict about other things like classes, so you may need to tune your log to be less harsh about warnings.
1
error_reporting = E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_NOTICE
But don’t ignore the warnings entirely because “deprecated” will one day turn into completely missing and fatal like mysql functions.

Sunday, October 6, 2019

How to Convert Apple QuickTime .MOV files to H264 on Ubuntu command line like a boss

Convert Your Bloated Apple QuickTime .MOV videos to H264 .MP4 with ffmpeg

Everybody knows that Apple QuickTime is an outdated and bloated video format that requires extra codecs to play on Windows 7 and 10, plus you need Apple Itunes or Apple QuickTime to play it back.  On Windows 7 and 10, you also need VLC media player or the codec pack to play it back with Windows Media player.  It's so bloated that a 3 minute video can easily fill up 1 GB of disk space.  Plus native QuickTime can easily fill up your icloud account.  Furthermore, it's an outdated format that will soon be obsolete. So, convert the videos to H264 video to compress down to 1/10 the file size and be playable on Windows Media Player and be ready for upload to YouTube.  Compress it and reduce the frame rate with ffmpeg to reduce the file size by 95% or more.

First thing you need is Ubuntu 14 to 16+ LTS running on a decent core i7 machine with at least 4 cores. Then once you get that, you need to use apt to install ffmpeg. 

Install the reposisitory and then install ffmpeg using these 3 commands.

sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get update
sudo apt-get install ffmpeg
Some basic things that you do:

Reduce .mov File Size:
ffmpeg -i in.mov -c:v libx264 -c:a copy -crf 20 out.mov
Convert .mov To .mp4
ffmpeg -i in.mov -vcodec h264 -acodec aac -strict experimental -ab 128k out.mp4

Convert a Lot of Files using this bash shell script
#! /bin/bash

##
## ALLMOVFILES=`find ./ -name "clip*.mov" -exec /bin/sed -e 's/\ /%20/g' '{}' ';'`
## ALLMOVFILES=`find ./ -name "clip*.mov" -exec echo '{}' | /bin/sed -e 's/\ /%20/g' ';'`
OUTDIR="./H264-Video"
ALLMOVFILES=`find ./ -name "clip*.mov" -exec echo '{}' ';' | /bin/sed -e 's/\ /%20/g'`

for INFILE in ${ALLMOVFILES}
do
   echo $INFILE

   FILENAME=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } {  print $NF; }'`
   DIRS=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } { for (i=1;i<NF;i++) { print $i;} }'`
   echo "Split with awk: " $DIRS
   for dir in $DIRS
   do
      echo "dir:" $dir
   done
   echo "file:" $FILENAME
   ofile=`echo $FILENAME | /bin/sed -e 's/%20/\ /g'`
   ifile=`echo $INFILE | /bin/sed -e 's/%20/\ /g'`
   ofile=`echo $ofile | /bin/sed -e 's/mov/mp4/g'`

   echo $ifile
   echo $ofile

   ffmpeg -i "${ifile}" -vcodec h264 -acodec aac -strict experimental -ab 128k "${OUTDIR}/${ofile}"

done
Here's the same things with pretty code

#! /bin/bash

##
## ALLMOVFILES=`find ./ -name "clip*.mov" -exec /bin/sed -e 's/\ /%20/g' '{}' ';'`
## ALLMOVFILES=`find ./ -name "clip*.mov" -exec echo '{}' | /bin/sed -e 's/\ /%20/g' ';'`
OUTDIR="./H264-Video"
ALLMOVFILES=`find ./ -name "clip*.mov" -exec echo '{}' ';' | /bin/sed -e 's/\ /%20/g'`

for INFILE in ${ALLMOVFILES}
do
   echo $INFILE

   FILENAME=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } {  print $NF; }'`
   DIRS=`echo ${INFILE} | nawk -F "/" 'BEGIN { FS="/"; } { for (i=1;i<NF;i++) { print $i;} }'`
   echo "Split with awk: " $DIRS
   for dir in $DIRS
   do
      echo "dir:" $dir
   done
   echo "file:" $FILENAME
   ofile=`echo $FILENAME | /bin/sed -e 's/%20/\ /g'`
   ifile=`echo $INFILE | /bin/sed -e 's/%20/\ /g'`
   ofile=`echo $ofile | /bin/sed -e 's/mov/mp4/g'`

   echo $ifile
   echo $ofile

   ffmpeg -i "${ifile}" -vcodec h264 -acodec aac -strict experimental -ab 128k "${OUTDIR}/${ofile}"

done

You can read more at:
https://tecadmin.net/install-ffmpeg-on-linux/

There are other command line apps to do the same thing. For example: avconv, vlc, and mencoder.  However, none of them can stand up to ffmpeg when it comes to QuickTime Video.