Avada Cache Buster

I use the Avada theme on some of my WordPress sites. However, when I update the style the browser continues using the cached version. To solve this, I wrote a little script to go in the child theme functions.php.

It changes Fusion’s CSS version to the time the folder was last modified, causing the browser to go and fetch the new file.

add_filter( 'style_loader_src', 'update_css_ver', 9999, 2 );

function update_css_ver( $src ) {
if ( strpos( $src, 'fusion' ) ) {
$src = remove_query_arg( 'ver', $src );
$upload_dir = wp_upload_dir();
$upload_dir2 = trailingslashit( $upload_dir['basedir'] );
$lastupdate = filemtime( $upload_dir2 . 'fusion-styles/' );
$src = ($src . '?' . $lastupdate );
}
return $src;
}

Quick Command Line Video Excerpt

Do you have a video file you want to extract a clip from?

I found it difficult to locate this information and learned a lot in the process. Most importantly, the order of options in avconv command matters. You can refer to the manual here.

avconv -ss [start time = hh:mm:ss] -i [input filename] -t [clip duration = hh:mm:ss or in seconds] -codec copy [output filename]

For example, to create a 79 second clip from a video file that starts at 58 minutes and 25 seconds in the original video:

avconv -ss 00:58:25 -i 1995-8mm-home-video.dv -t 79 -codec copy 1995-guinea-pigs-garage.avi

Lenovo Thinkpad Tablet 2 Reformat Guide

10/4/2017 Update: I was just in the bios and I tested the touch screen. It works for pretty much everything on the screen!

Check the end of the article for updated information about Windows 10.

Objective: Format the drive, install Windows 8.1, install minimum drivers and let Windows Update do the rest.

I bought the Tablet 2 in early 2013 but didn’t use it as much as I wanted because of it’s slow speed and inaccurate digitizer. A year and a half later I was ready to give up on it. The specs are low. I thought it would be impossible to ever be fast. After using Linux daily for many years I forgot the benefits of a clean Windows install. At the end of the day, my TPT2 is faster than it ever has been. In fact, it feels like a different machine.

You will need a few USB accessories: keyboard, mouse, flash drive, USB hub. You need the hub! Without a USB keyboard you will be unable to set the boot device or install Windows.

This is guide wasn’t intended to walk you through each key stroke or click to format your first computer. If this is your first time you will need some supplemental guidance from a begginer’s guide.

Write down your Windows 8 product key. You can use the Magical Jelly Bean Keyfinder, it is free.

Download Windows 8.1 iso. Don’t use the Microsoft upgrade program to download it or you will end up with a Windows 8 iso instead of 8.1. Instead find the torrent of the MSDN iso here. Don’t worry. You can verify it with the sha1 hash against MSDN’s to make sure you are getting the real thing. I used Windows 8.1 with Update (multiple editions) (x86) – DVD – MultiLang. Make this into a bootable flash drive. You can use a DVD if you have an external DVD drive available.

Boot from the USB drive. To get into the bios: press the power and volume up buttons at the same time.

Windows setup. Delete all the partitions. Create a new one with all the free space and agree when Windows setup says it may setup some extra partitions. You will need to use a Windows 8.1 generic key for the installation process. Don’t worry. After setting up the drivers to get WiFi working you can enter your Windows 8 key.

Setup minimum drivers to get Windows update working. Save the drivers on a flash drive. Download them from here. It maybe helpful to use the drop down menus to filter out the other choices. Install one at a time and reboot after each one if prompted.
1. Chipset => Intel Platform Driver for Windows 8.1
2. Networking: Wireless => Broadcom Wireless LAN driver for BCM4330 abgn for Windows 8.1
3. Mouse and Keyboard => WinTab Driver for Windows 8.1 (This is the driver and calibration software for the pen. It is Wacom specific so I suggest you install it.)

Activate Windows. Go ahead and try to activate. It will say your key isn’t valid and give you the option to enter a new one. Provide your original Windows 8 key.

Run Windows Update. Running this for the first time is excruciatingly slow. You will feel like it is stuck at 0% forever. You will think that something is not working. And even though I am telling you this, it is so slow that you will still think that something is not working correctly. Leave it for at least an hour or two and you should have a list of updates. Go ahead and select everything and install. Again, this is very slow. It will look stuck on 0%. Give it 2-3 hours and it should be nearly done.

Enjoy. Reboot and check Windows Update again. You should be done with the major stuff and have a bloatfree tablet. There will be two unknown items under unknown devices. I don’t know what they are. After using the new setup for a week I have not noticed anything missing or not functioning properly. In fact, I really love using the tablet now and I don’t really mind that it runs Windows!

A few last notes… I don’t recommend installing any of the other Lenovo software. On my first attempt I let Lenovo’s update program install everything it recommended and it slowed the tablet down. Like WAY down. The second time I did what I described above and if I was to do it all over again, I would do it the same way. Don’t forget to calibrate your screen using the Wacom tool in the control panel.

Consider installing Classic Shell. It is a free Start menu replacement which used to be open source. Then head over to Ninite to grab a customized installer to install all your programs. Last but not least, don’t forget to grab your free copy of OneNote. Note: The new free version does not properly import notebooks from Onenote 2007 that have PDF printouts with notes written on top. The first few pages of the section look okay. Scrolling down will reveal your writing progressively shifts up and is no longer aligned the way you wrote it on the printout.

Update 1/26/2015: In Windows power management you may notice the options are limited to one setting, balanced. To get even more performance you can install some registry patches that restore options under advanced power settings. So far I have added processor power management, wireless adapter settings, PCI express and created additional power profiles like high performance and battery saver.

Update 7/16/2015: Please read the comments below for some more helpful hints. Rick said he was able to create a Windows 8.1 clean install media straight from the tablet that includes all drivers and is activated. Roger was also able to help us figure out the two unknown devices, one being the Broadcom GNSS geolocation driver and the other is Atmel touch debug port driver boot bridge peripheral driver. Thank you kindly, gentlemen!

Update 8/4/2015: Windows 10!

It is possible – but my experience was sluggish compared to an already lackluster Windows 8.1. Here’s how I did it… By the way, I only ran it for a day, then returned to Windows 8.1.

Use the Media Creation Tool to setup the Windows 10 installer to a USB drive. I went with Windows 10 Pro 32-bit, as I currently have Windows 8.1 Pro 32-bit installed.

Boot from the USB drive. (Power and volume up buttons at the same time. Then set the USB drive as the first selection.)

Select “custom install” and then delete all partitions.

Select “Drive 0 Unallocated Space” and click next. The next part will take about 25 minutes until the next user input is required.

After you choose your settings and Windows finishes setting itself up, install the drivers.

For the chipset, I used the Acer Iconia W3 Windows 8.1 driver package. Run setup.exe from the “MI” folder. It is a bit newer than Lenovo’s – which did not provide functional drivers for everything under Windows 10. You will also need Lenovo’s Broadcom Wireless LAN driver for BCM4330 abgn, Broadcom GNSS Geolocation Driver, Atmel Touch Debug Port Driver, WinTab driver. For any devices remaining with a question mark, update their driver from a location on your computer, pointing it to the “MI” folder. If I recall correctly, that should take care of any remaining devices, or Windows Update will.

Windows Update will take some time to get going so be patient.

I ran some benchmarks and the results are as follows:

PassMark: 202.9
CPU Mark: 625
2D graphics mark: 81.5
Disk Mark: 187.5

If you were able to find a way to get the performance up to par – then please let us know! When I tried playing back 720p video on VLC, it was laggy and unwatchable!

Update 8/20/2016: Windows 10

I tried the free update to Windows 10 and it still felt sluggish. Went back to Windows 8.1!

How to get your Logitech DiNovo Mini to work in Ubuntu

I am writing this post because I forgot to bookmark the forum thread where I originally read the solution. So I backtracked using the .bash_history file, and compared it with an original version.

Start by unpairing the keyboard from your computer. Then open

/lib/udev/rules.d/97-bluetooth-hid2hci.rules

Remove

KERNEL=="hiddev*",

from the following line

KERNEL=="hiddev*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[345abce]|c71[3bc]", \

so it looks like

ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[345abce]|c71[3bc]", \

and reboot and pair it!

Compile Latest Ganglia for All Versions of Debian and Ubuntu

I have learned a lot since I wrote the original how-to. I do not have time to write a nice story but follow the steps below and you should be fine. This will provide you with the latest version of Ganglia on any Debian based distro.

Objectives:
1. Download latest sources from Ganglia git repository.
2. Compile, install and setup monitor-core.
3. Setup ganglia-web front-end.
4. Setup hsflowd on servers.

On your collector / PHP enabled web-server:

apt-get install build-essential automake autoconf pkg-config gperf libtool rrdtool librrd-dev libconfuse-dev libapr1-dev libpcre3-dev

cd ~
git clone https://github.com/ganglia/monitor-core.git ganglia
cd ganglia
git submodule init
git submodule update

./bootstrap

Update February 1, 2014: You need to install Concurrency Kit before running configure or it will fail.
Instructions:

"git clone http://concurrencykit.org/cgit/cgit.cgi/ck/"; "cd ck"; "./configure"; "make"; "make install"

and then switch back to your ganglia directory and continue.

./configure --with-gmetad
make
make install
ln -s /usr/local/lib64/ganglia /usr/lib/ganglia
useradd --system ganglia
groupadd --system ganglia

nano /etc/ld.so.conf
add line: /usr/local/lib

ldconfig

nano /usr/local/etc/gmetad.conf
change: data_source "your cluster name" 20 localhost
cp ~/ganglia/debian/gmond.conf /usr/local/etc/gmond.conf
nano /usr/local/etc/gmond.conf
change: mute = yes
change: name = "your cluster name"
change:
udp_send_channel {
  port = 8649
  ttl = 1
}
udp_recv_channel {
   port = 8649
}
sflow {
  udp_port = 8649
  accept_vm_metrics = yes
}
tcp_accept_channel {
  port = 8649
}

cd /var/www
git clone https://github.com/ganglia/ganglia-web.git ganglia
cd ganglia
mkdir dwoo/compiled
mkdir dwoo/cache
mkdir -p /var/lib/ganglia/rrds
chown nobody /var/lib/ganglia/rrds
chown -R www-data:www-data /var/www/ganglia
cp conf_default.php.in conf_default.php
cp version.php.in version.php
nano conf_default.php
change: $conf['gweb_confdir'] = "/var/www/ganglia";
change: $conf['gmetad_root'] = "/var/lib/ganglia";

gmond
gmetad

On servers you want to monitor:

apt-get install hsflowd

Note: This package does not appear to be included anymore. Visit their website.

nano /etc/hsflowd.conf
change: DNSSD = off
change: polling = 20
change: sampling = 2000
change:
collector {
ip = (IP running gmond+gmetad)
udpport = 8649
}

/etc/init.d/hsflowd start

Visit your webserver to see your graphs. DONE!

NOTE: There is a mistake in stacked.php as of January 16, 2013 which causes the graph to break. The exact error is: “PHP Parse error: syntax error, unexpected T_FOREACH in /var/www/ganglia/stacked.php”

To fix, search for “$min_index = min(array_keys($hosts))” and add a semi-colon to the end of the line:

nano /var/www/ganglia/stacked.php
change: $min_index = min(array_keys($hosts));

EDIT (8/5/2013): I recently read this article and decided to set my sampling rate to 2000. I was occasionally getting errors where my network speed was being measured in petabytes/s! Here is a second article about the same topic that is also worth a quick read.

New Server for a Small Office

I recently setup an HP 6200 Pro Small Form Factor PC. It had 12GB of RAM and 2x 250GB 7200RPM disks running software RAID 1 on CentOS 6.

It was for a small office where the server was 10 years old and died. This beauty is dual core with hyperthreading! A perfect candidate to virtualize 3 Windows XP machines and a Linux file server. The printers are setup on the host operating system since they are specific to that site.

The virtualizations can easily be migrated from office to office or accessed over the VPN. Employees and IT no longer need to worry about physically moving their computer from one site to another. Data will remain in a safe location and backups can be made regularly by the administrator.

Some people may be interested to know that there is a parallel port adapter available from HP. It connects directly to a pin-out on the motherboard. I used it to connect a Panasonic KX-P3196. I had to install kmod-lp for my printer to be detected.

To run KVM you will need to enable VT-x in the BIOS. Go through every menu and you WILL find it. If this is not enabled the KVM module for your CPU will not load.

I also setup a Turnkey Linux Core as a central samba server which will backup nightly to Amazon S3.

Three Windows XP virtualizations get one logical processor each and 2GB of RAM. The Turnkey Linux Core server gets 1GB of RAM and one logical processor.

I will update this post if there are any problems with this setup.

Reset Supermicro IPMI Password

I forgot my IPMI password. Did you do this too? Do you have root access via SSH to the installed operating system? If you answered yes to both these questions, I have good news for you.

Here is how to do this via SSH to the installed Linux operating system.

Download the IPMICFG utility on the Supermicro FTP.

Unzip it and set the appropriate file as executable. For me it is “ipmicfg-linux.x86_64.static”.

Use –help to view the available options.

I copied the values for the following: -m (show IP and MAC), -k (show subnet mask), -dhcp (get DHCP status), -g (show gateway IP), -vlan (get VLAN status).

Take a deep breath and reset to factory default (-fd). You should see: Reset to the factory default completed!

Update the settings and you should be good to go! The following is what I did to accomplish this.

Turn dhcp off (-dhcp off) and set the IP (-m ###.###.###.###). If you need to set a custom MAC (-a ##:##:##:##:##:##). I checked my IP and MAC (-m) and did not need to set the MAC.

Set the subnet mask (-k ###.###.###.###) and the gateway (-g ###.###.###.###).

Login using IPMI View. The default (case sensitive) login / pass is ADMIN / ADMIN. Go ahead and change the password! If you try to do this from the web interface it will not work.

Enjoy the great features which you have recovered!

Logrotate MySQL Cron Error

I have been receiving the following email report:

/etc/cron.daily/logrotate:
error: error running shared postrotate script for '/var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1

Most recommendations to fix this problem suggest updating the debian-sys-maint password for the MySQL server to match the one in /etc/mysql/debian.cnf.

This will not fix the problem if MySQL is not logging. Check if logging is turned on in /etc/mysql/my.cnf.

If you choose only to log errors then remove /etc/logrotate.d/mysql-server.

You should no longer get this error!!

phplist SMTP w/ SSL

Update (Nov 25, 2013): Instructions for version 3.0.5

1. Rename config_extended.php to config.php

2. Uncomment line 558.

define("PHPMAILER_SECURE",'ssl');

3. Set mail server on line 535.

define("PHPMAILERHOST",'smtp.yourdomain.com');

4. Uncomment line 543, 544, 547.

Fill in the username, password and SSL port number.

5. Set line 213 to 0.

define ("TEST",0);

The above steps should be all you need to do to setup SMTP w/ SSL on the current version. There is no longer a need to edit any file other than config.php.

Update (Aug 18, 2013): The newest version of phpList’s config.php has settings for using secure SMTP. I suggest you use the new config file by copying your settings from the old config file. Enjoy!

Update (Nov 20, 2012): This still works for 2.10.19! 🙂

Update (Nov 7, 2011): I just upgraded to 2.10.17 and can confirm this still works.

Original Post (Jun 7, 2011): When I updated phplist to 2.10.14 I forgot that there were a few modifications required for using SMTP with SSL. This may be the reason your phplist will not send mail.

Searching resulted in many forum threads which had numerous suggestions. I checked the old files and found that the following modifications, in the past, had allowed me to send mail via SMTP with SSL.

config/config.php settings:

define("PHPMAILER",1);
define("PHPMAILERHOST",'smtp.yourdomain.com');
$phpmailer_smtpuser = 'LOGIN';
$phpmailer_smtppassword = 'PASSWORD';
$phpmailer_smtpsecure = 'ssl';
$phpmailer_smtpport = 465;

Open admin/class.phplistmailer.php and locate:

$this->Password = $GLOBALS['phpmailer_smtppassword'];

Below it insert:

$this->SMTPSecure = $GLOBALS['phpmailer_smtpsecure'];
$this->Port = $GLOBALS['phpmailer_smtpport'];

Open admin/phpmailer/class.smtp.php and locate:

$this->smtp_conn = fsockopen($host,

Update

$host,

to

$host='ssl://smtp.yourdomain.com',

You should now be able to send mail!!

Setup PSAD in Ubuntu 9+

Psad scans your firewall log in real time. It can be configured to automatically drop packets and more. While reading the guides that are available for this I ran into a problem, there was no /etc/syslog.conf. On Ubuntu’s webpage I found this release note. It says that as of Ubuntu 9.10, syslog has been upgraded with rsyslog. This can make setting up psad a little tricky.

This guide has been tested on Ubuntu 10.04 LTS Server and 10.10 Desktop

The first thing to do is install psad:

sudo apt-get install psad

Now edit the config file:

sudo nano /etc/psad/psad.conf

Change “ENABLE_SYSLOG_FILE Y;” to “ENABLE_SYSLOG_FILE N;”. We will not need psad to read our syslog.

Another setting to review right now depending on your environment is “EMAIL_ALERT_DANGER_LEVEL”.

Set the email at the top of the config file or leave the default, root. I have root’s mail set to forward to my real email address. To forward root (or any user’s) mail: place a file named “.forward” in their home folder. Inside the file enter the email address where the mail is to go.

Restart psad:

sudo /etc/init.d/psad restart

Next: configure iptables to log the non-legitimate packets. The logging rules need to go after the accept rules but before the drop. Confusing? It was for me.

For example, my default policy for INPUT and FORWARD is to DROP. After this my accept rules for specific ports are appended. Meaning our logging rules must go at the end of the file, before they are dropped because the packets were not accepted by any previous rules.

$IPT -A INPUT -j LOG --log-prefix "firewall1 "
$IPT -A FORWARD -j LOG --log-prefix "firewall1 "

The prefix is going to allow rsyslog to filter the messages. After applying the log rules it is possible to view the end of the syslog to see if logging is working.

sudo tail /var/log/syslog

The last step is for rsyslog to send the messages that contain “firewall1” to psad’s pipe.

sudo nano /etc/rsyslog.d/50-default.conf

We are going to place our rules at the top of the file. That way we can stop “firewall1” messages from making it to any other logs.

:msg, contains, "firewall1" |/var/lib/psad/psadfifo
:msg, contains, "firewall1" ~

Note: the ~ means to discard.

That’s it! Restart rsyslog:

sudo restart rsyslog

To view psad’s status:

sudo psad --Status

Comments and suggestions are welcome!!