How to fix the Asus Zenbook trackpad

I have an Asus Zenbook for work, and its awesome. Small. light and fast!

Since day 1, the trackpad has been a huge issue. It didn’t perform like some previous laptops I had, nor like my Macbook. For instance when you single tap on the left or right buttons on the track pad, they register as single clicks. This messes things up from time to time. There are some other issue as well, my palm getting in the way and causing issues.

Anyways, I found somewhat of a solution to some of the issues. A personal blog provides some registry changes you can make to reveal more settings from the Elan trackpad program.

http://alonsrants.blogspot.ca/2012/01/asus-zenbook-touchpad-hack.html

The only problem is that when you save your settings after enabling the registry keys and re-open the Elan application, the extra options are removed. So I’ve provided a registry file that you simply run each time.

[download id=”5″]

UPDATE: 09/24/2014

Using the TouchPad blocker has made quite a difference, I suggest using this application.

http://www.mobilehealthcomputing.com/2012/07/touchpad-blocker-is-essential-app-for.html

Cheat Sheet for Administrating a PostgreSQL Database/Server

PostgreSQL Interactive Terminal

 

Postgresql is similar to MySQL in that it uses an interactive terminal. To gain access type the following as root

su - postgres -c psql

You’re now logged into the Postgresql interactive terminal and interacting with the local server.

Common Shell Commands

 

Dump a database.

When dumping and restoring a database, you have to work within the postgres user, this is the default setup. The home directory for the postgres user is /var/lib/postgresql

pg_dump -U username database -f file.sql

 

Restore a database.

In order to restore the database you will need to ensure that the database name exist, for instance if it was dropped.

psql -U username -d database -f file.sql

 

Common Interactive Terminal Commands

 

Connect to a database, like “use database” in MySQL.

connect databasename;

 

View current databases on local server

select datname from pg_database;

 

View current databases on local server

\l

 

 Show current roles

select rolname from pg_roles;

 

Create a user.

create user ramesh with password 'tmppassword';

 

Create a database.

CREATE DATABASE mydb WITH OWNER ramesh;

 

Drop database.

DROP DATABASE mydb;

If you notice that you’re unable to drop a database because of connections, then run the following.

SELECT
pg_terminate_backend(procpid)
FROM
pg_stat_activity
WHERE -- don't kill my own connection!
procpid <> pg_backend_pid();

If it’s a busy database then you may need to run the following first.

REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, username;

MikroTik – DynDNS Update Script

This is a script for ensuring that your DynDNS hostname is updated when your IP changes on your MikroTik router. Unfortunately the script from the MikroTik Wiki doesn’t work and is broken.

http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_dynDNS

  • There is a question mark within the URL that posts the update to members.dyndns.org and it gets removed when you paste and run the code through telnet/ssh. To fix it you will need to put a slash in-front of the question mark for it to be passed correctly.

This script is now on GitHub at https://github.com/jordantrizz/mikrotik-scripts/blob/master/dyn-dns

# Set needed variables
:local username "username"
:local password "password"
:local hostname "hostname"

:global dyndnsForce
:global previousIP 

# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: password = $password")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")

# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]

# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"

# Remove the # on next line to force an update every single time - useful for debugging,
# but you could end up getting blacklisted by DynDNS!

#:set dyndnsForce true

# Determine if dyndns update is needed
# more dyndns updater request details http://www.dyndns.com/developers/specs/syntax.html

:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
   :set dyndnsForce false
   :set previousIP $currentIP
   :log info "$currentIP or $previousIP"
   /tool fetch user=$username password=$password mode=http address="members.dyndns.org" \
      src-path="/nic/update\?hostname=$hostname&myip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG" \
      dst-path="/dyndns.txt"
   :local result [/file get dyndns.txt contents]
   :log info ("UpdateDynDNS: Dyndns update needed")
   :log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
   :put ("Dyndns Update Result: ".$result)
} else={
   :log info ("UpdateDynDNS: No dyndns update needed")
}

MikroTik – Backing Up Your MikroTik & Routerboard Config

Another great script that will email you a copy of your MikroTik/Routerboard device config. You can find the source on the MikroTik Wiki below.

http://wiki.mikrotik.com/wiki/Send_Backup_email

Some notes about the script on the MikroTik wiki and below.

  • I had to modify the script on the MikroTik website, it had used /tool e-mail set address instead of /tool e-mail set server.
  • Ensure that you specify an IP Address for sending an email, a host name will fail.

I’ve moved the code to GitHub just because its awesome and it will track changes! The latest code is available at https://github.com/jordantrizz/mikrotik-scripts/blob/master/backup

/export file=([/system identity get name] . "-" . \
[:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6]); \
/tool e-mail send to="[email protected]" subject=([/system identity get name] . " Backup " . \
[/system clock get date]) file=([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . \
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc"); :delay 10; \
/file rem [/file find name=([/system identity get name] . "-" . [:pick [/system clock get date] 7 11] . \
[:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".rsc")]; \
:log info ("System Backup emailed at " . [/sys cl get time] . " " . [/sys cl get date])

Please note: The code above was incorrectly formatted and may have had some characters changed or stripped when it was first posted. I have since updated the above code and it should be correct, if you have any issues then post a comment. -Jordan @ 09/12/12

MikroTik – Automatically creating DNS record for each DHCP lease/client

You’ll notice that when you first get your MikroTik router, that it doesn’t create DNS records for each DHCP client that successfully receives a lease. The below article provides the necessary script to create a DNS record for each DHCP Client. I’ve provided a link to the Mikrotik Wiki article so you can see the original source.

http://wiki.mikrotik.com/wiki/Setting_static_DNS_record_for_each_DHCP_lease

The script does need to be modified (white spaces taken out) so that it will run correctly on the MikroTik. I’ve done this already and provided the script below. Also, make sure that you change :local zone “local”; to your network domain name or dns search suffix.

You will also have to create this script via telnet/ssh as webfig will mess up line 11 and remove the “\\” and leave “\”. If you don’t know how to add a script via telnet/ssh, simply type system script add name=”dhcp-dns” soruce={ at which point you can then paste the script content below. You will then have to complete the line by entering in again.

Viola! Execute the script to ensure it runs without errors system scripts run name=dhcp-dns. Lastly we want to run this script often, to ensure the records are created and updated. Lets set a schedule run system scheduler add name=dhcp-dns-run interval=5m on-event=dhcp-dns and now the script should be running every 5 minutes. To confirm the scheduler is working, wait 5 minutes and then run system scheduler print and look at the “RUN-COUNT” value, which should be greater than 0.

This script is now in GitHub and can be seen here https://github.com/jordantrizz/mikrotik-scripts/blob/master/dhcp-dns

:local zone "local";
:local ttl "00:05:00"
:local hostname
:local ip
:local dnsip
:local dhcpip
:local dnsnode
:local dhcpnode

/ip dns static;
:foreach i in=[find where name ~ (".*\\.".$zone) ] do={
  :set hostname [ get $i name ];
  :set hostname [ :pick $hostname 0 ( [ :len $hostname ] - ( [ :len $zone ] + 1 ) ) ];
  /ip dhcp-server lease;
  :set dhcpnode [ find where host-name=$hostname ];
  :if ( [ :len $dhcpnode ] > 0) do={
    :log debug ("Lease for ".$hostname." still exists. Not deleting.");
  } else={
# there's no lease by that name. Maybe this mac has a static name.
    :local found false
    /system script environment
    :foreach n in=[ find where name ~ "shost[0-9A-F]+" ] do={
       :if ( [ get $n value ] = $hostname ) do={
         :set found true;
       }
    }
    :if ( found ) do={
      :log debug ("Hostname ".$hostname." is static");
    } else={
      :log info ("Lease expired for ".$hostname.", deleting DNS entry.");
      /ip dns static remove $i;
    }
  }
}

/ip dhcp-server lease;
:foreach i in=[find] do={
  :set hostname ""
  :local mac
  :set dhcpip [ get $i address ];
  :set mac [ get $i mac-address ];
  :while ($mac ~ ":") do={
    :local pos [ :find $mac ":" ];
    :set mac ( [ :pick $mac 0 $pos ] . [ :pick $mac ($pos + 1) 999 ] );
  };
  :foreach n in=[ /system script environment find where name=("shost" . $mac) ] do={
    :set hostname [ /system script environment get $n value ];
  }
  :if ( [ :len $hostname ] = 0) do={
    :set hostname [ get $i host-name ];
  }
  :if ( [ :len $hostname ] > 0) do={
    :set hostname ( $hostname . "." . $zone );
    /ip dns static;
    :set dnsnode [ find where name=$hostname ];
    :if ( [ :len $dnsnode ] > 0 ) do={
# it exists. Is its IP the same
      :set dnsip [ get $dnsnode address ];
      :if ( $dnsip = $dhcpip ) do={
        :log debug ("DNS entry for " . $hostname . " does not need updating.");
      } else={
        :log info ("Replacing DNS entry for " . $hostname);
        /ip dns static remove $dnsnode;
        /ip dns static add name=$hostname address=$dhcpip ttl=$ttl;
      }
    } else={
# it doesn't exist. Add it
      :log info ("Adding new DNS entry for " . $hostname);
      /ip dns static add name=$hostname address=$dhcpip ttl=$ttl;
    }
  }
}

 

 

*UPDATE 10/01/2014* A much better script has been created by Tyler and is available at http://www.tolaris.com/2014/09/27/synchronising-dhcp-and-dns-on-mikrotik-routers/

Upgrading Zen Theme Foundation (Confluence) Brand from 3 to 4.1.4

If you have a custom brand for your Zen Theme Foundation plugin, and upgraded the plugin from version 3 to 4.14. You might have noticed that some images are missing, or you might not even noticed them missing because no missing image is displayed.

To fix this, I just copied over the missing images from the Breeze template. Here is a list of them.

check-large.png
non-master.gif
non-master-hover.gif
tack-on.png
tack.png
trash.gif
trash-hover.gif
trash-large.png
toolbar-background.gif
toolbar-hide-on.png
toolbar-hide.png
toolbar-show-on.png
toolbar-show.png
master-draft.png
master.gif
master-hover.gif
master-watermark.png

Cisco ASA Lost Config After Power Cycle

I ran into this recently where a Cisco ASA was powered off accidentally, and lost a whole month of config changes. The firewall still operated because it still had a config, just nothing from a month ago.

I then decided to log into the Cisco ASA and type “write mem” and got the following error.

Result of the command: "write mem"

Building configuration...

Cryptochecksum: 22387bc0 13130870 b142ffd2 c97d2014

%Error opening disk0:/.private/startup-config (Read-only file system)

Error executing command

[FAILED]

This is what Cisco had to say about the issue.

 

Error when wr mem command issued

This error appears when you try to save the configuration with the wr mem command:

%Error opening disk0:/.private/startup-config (Read-only file system)

Error executing command

In order to resolve this, perform a filesystem check so that the error can be removed. This command sequence is presented for your reference.

CiscoASA# wr mem
Building configuration…
Cryptochecksum: 2e24ca48 2496fe80 51a4ecbb 81a2dba5

%Error opening disk0:/.private/startup-config (Read-only file system)
Error executing command
[FAILED] CiscoASA# fsck disk0

fsck of disk0: complete
CiscoASA#
pehac-a0-df01# fsck flash

fsck of flash: complete
CiscoASA# wr mem
Building configuration…
Cryptochecksum: 2e24ca48 2496fe80 51a4ecbb 81a2dba5

22851 bytes copied in 3.400 secs (7617 bytes/sec)
[OK]

What really grinds my gears is that I didn’t get a notification from ASDM GUI that the “write mem” command failed!

Here’s more information from Ciscos website:

http://www.cisco.com/en/US/products/ps6120/products_tech_note09186a0080b95d3d.shtml

Moving WordPress to a New Domain Name

So there are a couple of things that you’ll need to do before to ensure a successful move of your WordPress Installation to a new domain name.

1. I’m sure you know how to copy all of the WordPress Files and Database to the new location where the new domain name has been setup. I’m not going to cover this, because I think its pretty straightforward and easy to find online.

2. After the move, you might notice that you’re unable to login to the admin interface “wp-admin”. A simply edit to the wp-config.php file will resolve that quickly. Place the following in the wp-config .php file within the root of your WordPress installation.

define('WP_HOME','http://geektank.net');
define('WP_SITEURL','http://geektank.net');

The domain name ‘geektank.net’ would be the new domain name, once the file has been modified and uploaded. You should be able to login to the admin interface at “wp-admin” again.

3. The next big issue you will find is that some plugins and images will still retain the old domain name. This is something that you will need to change manually by searching for the old domain name in your database using “phpMyadmin”.

Once I find a table with 10+ entries, I run a phpMyadmin query and do a search and replace.

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

Once you run the query, if you do another search you’ll won’t find the old domain name being referenced in those tables anymore.

Viola, you’re done. If you need more instruction on how to complete the above tasks. Post a comment and I will update this post!

WordPress and Protecting Directories with .htaccess

You’ll find sometime that when you deploy WordPress in order for permalinks to work correctly you need a proper .htaccess file. This .htaccess also affects anything else you place within your web root when WordPress lives.

For instance if you need to password protect a directory within the your webroot where WordPress lives. You’ll find that when you do so, and try to visit that folder in a web browser that a 404 WordPress page will be displayed. To fix this, you simply need to add the following to your main .htaccess file that has your WordPress rules.

ErrorDocument 401 default

This should then allow you to use your password protected directories as you normally would if you didn’t have WordPress installed.

Source: http://www.andrewrollins.com/2008/01/22/wordpress-and-htaccess-password-protected-directories/