Skip navigation

Category Archives: Uncategorized

This shouldn’t have taken me as long as it did, but Java’s JDBC driver doesn’t always know what TZ to use or rejects what the system returns. You may see something like: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The server time zone value 'CDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)

Yes, the mis-spelling of ‘specific’ is accurate to the output as out OpenJDK 1.8.0_181

You can attempt to push the TZ from the Java application but there’s no good reason the MySQL server shouldn’t be configured with a TZ. Check the server with:
SELECT @@global.time_zone

Then update /etc/myc.cnf with default-time-zone=Your/Timezone and restart.

If the server refuses to start and your sure of your timezone in my.cnf the MySQL tables might not be fully populated, to do so execute mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p from a terminal on the server host.

refs:
MySQL Documentation on Default Timezone

The ability to generate 3D objects from drawings isn’t a new technology, CNC lathes have been producing accurate three dimensional objects for decades out of a wide array of materials from various metals, wood, and plastics. Recently a far cheaper alternative known as 3D printing has become popular which can achieve a similar effect though in smaller scales and typically using less durable materials, which for most consumer/hobbyist goals is perfectly adequate. If you need a part that just isn’t made and know your way around a CAD tool, 3D printing is fast and cheap compared to what were at the time the only alternatives a few years ago.

For this project, I needed an extra set of fans to help cool the GPU within a CaseLabs Mercury S5. The S5 is by far one of the highest quality and best designed cases I’ve ever used, though my particular air-cooled configuration was plagued with a bit more heat soak than I was happy with. I think at some point everyone goes through a liquid cooling phase, and ultimately grows out of it. For anyone running an air-cooled setup in an S5, here’s an easy way to improve the flow dynamics of the PCI-E compartment.

To design the manifold I spent an afternoon re-familiarizing myself with the latest version of AutoCAD using the free 30 day trial license. AutoCAD’s 3D tools have come a long way in the last few years and made the design phase a breeze. For the fans I selected a set of 40mm Noctua NF-A4x10 low noise fans. Knowing the dimensions of the fans and having direct access to the case I used a digital caliper to measure the location the manifold was to be placed and created the 2D overhead drawing using the SW corner as the origin.

Screenshot (15)

The next step was to extrude/pull the 2D structures into the final form of the manifold. A quick review of a few chapters in an undergrad physics book covering laminar flow/fluid dynamics and some dirty napkin mathematics provided the offset of the fan face and the rear ventilation plate, use of the filet tool to eliminate sharp edges in the flow path to reduce turbulence/resistance and noise resulted in a compact and low material design. It is important at this stage to understand the limitations of the particular material and printer you will be using, they all have specific resolutions and minimum thickness guidelines that need to be considered during design. For my particular combination I targeted a minimum of 1.2 mm. I had also already selected a set of nylon mounting hardware to reduce vibration and was able to incorporate structures to increase strength and rigidity as well as specific geometry to hold the mounting hardware in place.

Screenshot (10)

Screenshot (12)

Screenshot (16)

Screenshot (18)

Screenshot (20)

Once the final design was achieved, and all measurements double checked it was time to print. I chose my local UPS store for convenience, which uses a Stratasys uPrint SE Plus.

IMG_20151220_071011

IMG_20151220_071211

IMG_20151220_072913

Results were far better than expected and whisper quiet. The total printing cost was ~$21 USD, the fans were on sale for $8 a piece which brought the total cost (not including personal time) to ~$37 USD.

The final DWG and STL files:
40mmHood_1.3_EXP2.dwg
40mmHood_1.3_EXP2.stl

GDChart is a fairly old PHP extension, it’s origins are somewhere in 2003 and doesn’t seem to have been updated since 2006. The standard PECL sources won’t compile under any version of PHP greater than 5.3 due to a few changes in the Zend engine and GD dependencies. If you try, you’ll get a few error messages:
/gdchart-0.2.0/gdchart.c:195: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘gdchart_functions’
/gdchart-0.2.0/gdchart.c: In function ‘gdc_objects_new’:
/gdchart-0.2.0/gdchart.c:303: error: ‘zend_class_entry’ has no member named ‘default_properties’
/gdchart-0.2.0/gdchart.c: At top level:
/gdchart-0.2.0/gdchart.c:360: error: ‘gdchart_functions’ undeclared here (not in a function)

If you’re in a hurry or your C/C++ is a little rusty you’re in luck, this is how to fix it. In the source file gdchart-0.2.0/gdchart.c perform these replacements:

195c195
< function_entry gdchart_functions[] = {
---
> zend_function_entry gdchart_functions[] = {
303c303
< 	zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
---
> 	object_properties_init((zend_object*) &(intern->zo), class_type);

Then perform the usual extension compilation routine:
gdchart-0.2.0]$ phpize
gdchart-0.2.0]$ ./configure
gdchart-0.2.0]$ make && make test

As you can see, you’re not done. Don’t try to install this module yet it won’t load, failing with PHP Warning: PHP Startup: Unable to load dynamic library '/home/jack/build/gdchart-0.2.0/modules/gdchart.so' - /home/jack/build/gdchart-0.2.0/modules/gdchart.so: undefined symbol: php_gd_gdFontMediumBold in Unknown on line 0

Now we have to patch some PHP GD core files to accommodate changes in the visibility of a few GD resources, fortunately we have a patch for that here:https://github.com/arete/t2/blob/master/package/php/php/libgd-symbol-visibility.patch.

After patching the PHP sources, recompile and install along with the GDChart extension. Or do what any sane person would do and use a more recent and maintained visualization library like PHPlot, pChart or Google Charts.

Spectrum analyzers are neat, software spectrum analyzers are not quite as neat but still useful. Spek (spɛk/, ‘bacon’ in Dutch) is a great library that provides a fast and accurate method to generate spectrograms. For one reason or another, it’s missing from recent repositories for RHEL derivatives, in this case Fedora 22. No worries, you can find the source on GitHub here.

Maybe you’ve broken your legs and are desperate for reading material, or have some neurological condition which compels you to actually read the instructions and attempt to run the autogen script and get a series of nasty error messages like
autoreconf: Entering directory `.'
autoreconf: running: intltoolize --automake --copy --force
autoreconf: running: aclocal --force
configure.ac:40: warning: macro 'AM_OPTIONS_WXCONFIG' not found in library
configure.ac:42: warning: macro 'AM_PATH_WXCONFIG' not found in library
autoreconf: configure.ac: tracing
autoreconf: configure.ac: AM_GNU_GETTEXT_VERSION is used, but not AM_GNU_GETTEXT
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:40: error: possibly undefined macro: AM_OPTIONS_WXCONFIG
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:42: error: possibly undefined macro: AM_PATH_WXCONFIG
autoreconf: /usr/bin/autoconf failed with exit status: 1

First of all, if you’ve gotten this far you obviously have autoconf, automake, intltool, etc. already installed. Good job. What you are missing are a few of the pkg-config dependencies for GTK, which will be confusing because on Fedora at least these packages will be under wxGTK + wxGTK-devel, so to fix this:
sudo dnf install wxGTK wxGTK-devel

Now clean up your build dir with GIT and ./autogen.sh again.

This is a simple bash script you can use to quickly convert a folder of music in AAC or FLAC into MP3 for use on a mobile device or small storage. To accommodate different input formats simple change the file suffix in the first line and the name variable regular expression from ‘mp4’ to ‘m4a’ or ‘flac’, etc. To use, copy/paste the script into a file within the folder to be converted and save it, then $chmod +x the_file_name and run the script ./the_file_name
The Script:

#!/bin/bash
for f in *.mp4
do
    name=`echo "$f" | sed -e "s/.mp4$//g"`
    ffmpeg -i "$f" -vn -ar 44100 -ac 2 -ab 320k -f mp3 "$name.mp3"
done

This script relies upon ffmpeg compiled with mp3 support (lamemp3).

I’ve recently gotten back into high end audio equipment with the purchase of a pair of Sennheiser HD 800 headphones. I’ve had a quality set of home shelf speakers for many years now but they aren’t something I can take into work or anywhere for that matter. For anyone who’s still with me on this, you know the difference a pair of high end speakers or headphones can make in the sound and clarity of music compared to even expensive ear buds or car stereo speakers. There really is no comparison.

The downside to this is that any of your music that has been compressed into MP3, M4A, etc. sounds thin, hollow and lifeless if recorded well to begin with. This has inspired me to begin to rebuild much of my music library that isn’t already in FLAC and along the way I thought I’d run a spectrum analysis of a song to document various levels of compression and the inherent data loss they incite.

Audio Sprectrum

The top graph represents the FLAC 44.1kHz sample, the middle represents 256kbs Mp3, and the bottom represents ~174kbps VBR Mp3. The frequency cutoff, banding and definition loss are obvious just looking at the graph and if you know the song well even more so upon listening. It is true you won’t be able to notice much of a difference withoput high quality audio components but given today’s high availability of cheap storage there is no good reason not to store your catalog in lossless or at least low-loss formats (>256kbs). Need to fit alot of music onto a smaller mobile listening device? Encode the music from the lossless sources when you need to, keeping the original as a backup (example).

This is a peculiar series of errors but I’m certain that I’m not the first to encounter. If you find yourself in need of the Authen::Libwrap perl library and have tried the usual install mechanisms YUM and CPAN without success then keep reading. the problem is you are missing a few packages not diretly listed in the prerequisites, namely tcp_wrappers, tcp_wrappers-devel, and the perl modules Local::Lib and Test::Exceptions. The Test module is used during the manual build of the Authen::Libwrap module. Soo…

$sudo yum install tcp_wrappers tcp_wrappers-devel
$sudo perl -MCPAN -e install Test::Exceptions
$sudo perl -MCPAN -e install Local::Lib

Then you’ll need to manually build the Authen::Libwrap libraries if your repo doesn’t have them:
$wget http://www.cpan.org/authors/id/D/DM/DMUEY/Authen-Libwrap-0.22.tar.gz
$cd Authen-Libwrap-0.22 && perl Makefile.PL && make
$make test
$sudo make install

The WSO2 framework provides comprehensive WSS, WSI security for SOAP and REST based web services with bindings in multiple languages including Java, PHP, Python, C, Ruby and many more. Unfortunately if you are attempting to compile this library extension for PHP > 5.3, you are going to have a bad time.

The first error you will run into is php zend_class_entry has no member named default_properties

The second error once you find a way around that one is php struct_php_core_globals has no member named safe_mode These are both due to changes made in PHP since 5.4, for “Safe Mode” specifically since the concept was deprecated in 5.3 and removed in 5.4, see PHP Safe Mode for more details.

The third error you may encounter is along the lines of error CHECKUID_CHECK_FILE_AND_DIR undeclared which is also due to deprecated/retired components of PHP.

Fortunately the fixes are few and easy, here are the patches:

src/wsf.c:

@@ -458,8 +458,12 @@
 
     ALLOC_HASHTABLE(intern->std.properties);
     zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
+#if PHP_VERSION_ID < 50399
     zend_hash_copy(intern->std.properties, &class_type->default_properties,
             (copy_ctor_func_t) zval_add_ref, (void *) & tmp, sizeof (void *));
+#else
+    object_properties_init((zend_object*) &(intern->std.properties), class_type);
+#endif
 
     retval.handle = zend_objects_store_put(intern,
             (zend_objects_store_dtor_t) zend_objects_destroy_object,

src/wsf_util.c:

@@ -1986,10 +1986,6 @@
 
 	if (VCWD_REALPATH(path, resolved_path_buff)) 
 	{
-		if (PG(safe_mode) && (!php_checkuid(resolved_path_buff, NULL, CHECKUID_CHECK_FILE_AND_DIR))) 
-		{
-			return NULL;
-		}
 
 		if (php_check_open_basedir(resolved_path_buff TSRMLS_CC)) 
 		{

You’ll notice that in wsf_util.c we simply removed that particular check because both functions/values no longer existed, there may be a better solution to this but for the moment we are able to compile. Rember to make clean then ./configure
make
sudo make install
and add the extension ini to /etc/php.d/

Done.

Having trouble finding the sources? Try the GitHub repo here or from the WSO2 site here. For some reason trying to wget that last URL resulted in 403 denied for me, but I was able to DL using a browser.

How to modify GitWeb to include the Google Prettify (PrettyPrint) JS and CSS to colorize your git repo web display, because why not. This applies to GitWeb 1.8.3, though finding the proper lines in previous version is not difficult.

To see the patch and the result in action, see the commit here.

HHVM, the HipHop Virtual Machine created by Facebook is pretty cool, bringing C like performance and scale-ability to the PHP crowd. PHP certainly is not my favorite language but if you need something deployed on a generic platform quickly and network accessible, PHP is a good starting point.

There are a number of good resources on the net for this, but like all the posts here they are notes for myself and what worked for me.

Get the required packages for compilation:

sudo yum install git svn cpp make autoconf automake libtool patch memcached gcc-c++ cmake wget boost-devel mysql-devel pcre-devel gd-devel libxml2-devel expat-devel libicu-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel binutils-devel pam-devel elfutils-libelf-devel

For CentOS there are a couple libraries that are too old for HHVM, and we have to compile/install them first. Like libmcrypt, we need the development library as well:

cd ~/dev
wget 'http://pkgs.repoforge.org/libmcrypt/libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm'
wget 'http://pkgs.repoforge.org/libmcrypt/libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm'
rpm -Uhv libmcrypt-*.rpm

and GMP:

wget https://gmplib.org/download/gmp/gmp-5.1.3.tar.bz2
tar jxf gmp-5.1.3.tar.bz2 && cd gmp-5.1.3/
./configure --prefix=/usr/local/gmp
make && make install
cd ..

and mpfr:

wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2
tar jxf mpfr-3.1.2.tar.bz2 ;cd mpfr-3.1.2/
./configure --prefix=/usr/local/mpfr -with-gmp=/usr/local/gmp
make && make install 
cd ..

and mpc:

wget http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
tar xzf mpc-1.0.1.tar.gz ;cd mpc-1.0.1
./configure --prefix=/usr/local/mpc -with-mpfr=/usr/local/mpfr -with-gmp=/usr/local/gmp
make &&make install
cd ..

make sure you have ncurses and ncurses-devel:

sudo yum install ncurses-devel

now build the cmake utility:

wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
tar -xvzf cmake-2.8.12.1.tar.gz 
cd cmake-2.8.12.1
./configure
make
sudo make install

Google Glog, for this we are going to need libcurl which is not mentioned in the docs:

sudo yum install libcurl

now glog:

svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog
cd google-glog/
./configure --prefix=/usr
make
sudo make install

Now we need jemalloc:

wget http://www.canonware.com/download/jemalloc/jemalloc-3.0.0.tar.bz2
tar -xvzf jemalloc-3.0.0.tar.bz2 
cd jemalloc-3.0.0
./configure --prefix=/usr
make
sudo make install

libmemcached, I was already running a Memcache serer under a few services, so for me I had to un-install and rebuild:

wget https://launchpad.net/libmemcached/1.0/1.0.17/+download/libmemcached-1.0.17.tar.gz
tar -xvzf libmemcached-1.0.17.tar.gz 
cd libmemcached-1.0.17
./configure --prefix=/usr
make
sudo service memcached stop
sudo yum remove libmemcached
sudo make install
cd ..

Now tbb, NOTE – Centos 6.3 does have tbb available but again it’s not recent enough so avoid the temptation to yum it. I also had to make some adjsutments to the install process, though this might be avoided with a more specific set of config flags:

wget 'http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120613oss_src.tgz'
tar -xvzf tbb40_20120613oss_src.tgz 
cd tbb40_20120613oss
make
sudo mkdir -p /usr/include/serial
sudo cp -a include/serial/* /usr/include/serial/
sudo mkdir -p /usr/include/tbb
sudo cp -a include/tbb/* /usr/include/tbb/
sudo make install
sudo cp build/linux_intel64_gcc_cc4.7.3_libc2.12_kernel2.6.32_release/libtbb.so.2 /usr/lib64/
sudo ln -s /usr/lib64/libtbb.so.2 /usr/lib64/libtbb.so

libdwarf, I got lazy here and yum’d it and it worked, so moving on:

sudo yum install libdwarf libdwarf-tools libdwarf-devel

now boost, this one also took a while. Make sure you have python and related devel libs installed:

wget http://downloads.sourceforge.net/project/boost/boost/1.50.0/boost_1_50_0.tar.bz2
tar -xvjf boost_1_50_0.tar.bz2 
cd boost_1_50_0
./bootstrap.sh --prefix=/usr --libdir=/usr/lib
./bjam --layout=system install
sudo ./bjam --layout=system install

and finally, GCC. this one takes a awhile, so find something to do. I actually used the newest version of GCC from http://gcc.gnu.org/releases.html which requires a newer version of the cmake utility::

wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.7.3.tar.bz2
tar jxf gcc-4.8.2.tar.bz2 ;cd gcc-4.8.2
./configure --prefix=/usr/local/gcc -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ -with-gmp=/usr/local/gmp -with-mpfr=/usr/local/mpfr/ -with-mpc=/usr/local/mpc/

this compile line worked better for me on a seemingliy identical Centos image:

./configure --prefix=/usr --with-libdir=lib64 --with-gmp=/usr/lib64 --with-mpfr=/usr/lib64 --with-mpc=/usr/lib64

Now we are ready for HHVM. this is a large download even through GIT:

git clone git://github.com/facebook/hhvm.git
cd hhvm
export CMAKE_PREFIX_PATH=/usr
export CMAKE_PREFIX_PATH=`pwd`/../usr
export HPHP_HOME=`pwd`

Build HHVM:

git submodule init
git submodule update --recursive
export HPHP_HOME=`pwd`
cmake .
make

If this works, you’re home. Check your install with the version command:

hhvm --version