Onscreen Keyboard

When using Remote desktop to change your password, you have to press ctrl-alt-delete.

Usually you can use ctrl-End on your remote machine — but sometimes that doesn’t work.

Using the windows onscreen keyboard will do the trick.

Run -> enter osk.exe in the cmd box.

This will pop up the onscreen keyboard. If you press Ctrl – Alt – you’ll see the keys on the onscreen keyboard light up – -then just click the DELETE button on the onscreen keyboard and it will pop up the task manager screen where you click change password.

Posted in Uncategorized | Leave a comment

crontab to check for updates on Redhat or Centos

This is the entry we use to check for updates everynight. If updates are available it will download them and send email so you can just jump on machine and do yum update -y

6 5 * * * /usr/bin/yum -q check-update > /etc/motd 2>&1 || /usr/bin/yum upgrade -y –downloadonly | mailx -s “yum updates on `uname -n`” kmeek@meekconsulting.com

Posted in Uncategorized | 1 Comment

perl toggle operator for extracting one table from mysql dump file

We did it with a nifty one liner perl command that uses the TOGGLE operator.

zcat fast.dmp.12082014_13_03.sql.gz |perl -ne 'if (/CREATE TABLE `budget`/../UNLOCK/ ) {print $_; }' > budget.1208.sql

This looks for lines in the dump between lines that match the green and yellow highlighted words ( which happen to be the separators we want )

We wanted to be able to rename our table so we could load it in the current schema as the live table so we added a substitution before printing like this:

zcat fast.dmp.12082014_13_03.sql.gz |perl -ne 'if (/CREATE TABLE `budget`/../UNLOCK/ ) {$_=~s/budget/budget_1210/; print $_; }' > budget.1208.sql

Good thing to have in your toolkit..

Posted in Uncategorized | Leave a comment

Keep submit buttons from submitting twice

Jquery One function works nicely for limiting a bind event to only one time.

Just be sure to re-bind it ONE time when the server sends back an error when validating the form inputs.

$objResponse->script(" $('#submit_edit_prod_personalization_form').button().one('click',function() { xajax_update_prod_personalization(xajax.getFormValues('edit_prod_personalization_form')); });");

Posted in Uncategorized | Leave a comment

Quick way to find IP address

Here is a quick way to find the external IP address of a system.  It can be used scripts etc

wget http://ipinfo.io/ip -qO –

Posted in Uncategorized | Leave a comment

Find out what CAs a webserver will accept

Here is a handy command to find out what CAs are accepted by a website.  When your website is configured to require client PKI certificates with the SSLVerifyClient require directive, it will only accept client certificates issued by CAs that you trust as defined in your SSLCACertificateFile  directive.

We usually set our up like this:

SSLCACertificateFile /etc/httpd/ssl/ca-bundle.crt

If you want to verify what is in that file for a remote host without going to the server you can run this command from any client.  It will simulate a web client and the server tells it what CAs are trusted and it will print them out.  Pretty neat!

openssl s_client -showcerts -connect beta.usecobra.com:443 –prexit


Posted in Uncategorized | Leave a comment

Setting up NTP to keep server time in sync

Install ntp packages

yum install ntp

Redhat 5 need ntpdate separately

yum install nptdate

Set ntp to start on boot:

chkconfig –level 345 ntp on

chkconfig –level 345 ntpdate on

For redhat 7:

systemctl enable ntpd.service

Verify with this:

chkconfig –list | grep ntp

Should show on for boot levels 3,4,5

chkconfig –list | grep ntp
ntpd            0:off   1:off   2:off   3:on    4:on    5:on    6:off
ntpdate         0:off   1:off   2:off   3:on    4:on    5:on    6:off

Edit the config file if you want to use local server

You can change the servers it uses to sync with to be local domain controllers if you don’t have access to the public NTP servers.

The default settings use round robin pools and send you to random servers in the time server pool.

To change edit the Config File /etc/ntp.conf

Change the server lines:

server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst

Start the service:

systemctl start  ntpd.service


service ntpd start

Check it is working:

If it is done right you should be able to see the peers actively being used:

ntpq -p

remote           refid      st t when poll reach   delay   offset  jitter


+tcgalxdc02.colu        3 u    –   64  377    0.909   18.481  11.071

*tcghqdc04.colum  2 u    7   64  377   25.665   43.190  15.213

If the delay / offset / jitter are zero — it means it is not getting to the server   check the firewall is allowing port 123 traffic for ntp through.

Posted in Uncategorized | Leave a comment

Quick HTTP server

If you need to pull files from a linux box.  This handy python command will turn on a temporary HTTP server listening on port 8000


cd to directory you want to pull files from and type:

python -m SimpleHTTPServer 8000


Lasts only until you kill the process with Crtl-C

Make sure you have firewall open to allow access to port 8000



Posted in Uncategorized | Leave a comment

TinyMCE — stripping junk when pasting from word

This will strip all annoying extra nonsense when copy/pasting from Word:

selector: “textarea”,
menubar: false,
plugins: “paste”,
paste_as_text : true,
paste_data_images: false,
paste_word_valid_elements: “”,
paste_webkit_styles: “”,
paste_retain_style_properties : “”,
toolbar: “insertfile | bold italic | bullist numlist”,
height : “500”

Posted in Uncategorized | Leave a comment

Handling Errors in MYSQL Procedures with Rollback

f you have mysql stored procedure that changes database tables — you probably want to enclose the whole procedure in a single transaction and add error handling to roll back the work if anything fails.

Here is how to do it:
Key points:
Use COMMIT at end

Turn on Transactions with START TRANSACTION after the BEGIN

And end the transaction with COMMIT at the end of your procedure

Add an error handling block that calls ROLLBACK work if there is any SQL EXCEPTION.

This is example SENDs a custom crafted ERROR message ( similar to RAISE_APPLICATION_ERROR in ORACLE ) which our PHP code recognizes and displays / logs.

Here is the magic:
PROCEDURE bocs_create_budget(psource_bud_id INT(11), ptitle VARCHAR(200), pfy INT(4), pout_years INT(11))

DECLARE new_bud_id INT(11);

@errno = MYSQL_ERRNO, @text = MESSAGE_TEXT;
SET @full_error = CONCAT(“ERROR “, @errno, ” (“, @sqlstate, “): “, @text);
SET MESSAGE_TEXT = @full_error, MYSQL_ERRNO = 1001;



— Procedure work that may raise errors is done here


END $$

Posted in Uncategorized | Leave a comment