How To Scroll to the Top of the Page using Javascript

Author: , Posted on Tuesday, March 20th, 2018 at 3:30:54pm

window.scrollTo(x-coord, y-coord);

Example: window.scrollTo(0,0);

R.I.P. Stephen Hawking

Author: , Posted on Wednesday, March 14th, 2018 at 8:33:23am
R.I.P. Stephen Hawking 1942-2018, a renowned physicist and ambassador of science.

R.I.P. Stephen Hawking 1942-2018, a renowned physicist and ambassador of science.

How To Expand a Filesystem on AWS Linux

Author: , Posted on Tuesday, March 6th, 2018 at 6:50:19am

This only works on the new expandable volumes. YMMV, as always.

1. Examine
file -s /dev/xvd*
df -h

2. Grow partition
Expand the modified partition using growpart (and note the unusual syntax of separating the device name from the partition number):
growpart /dev/xvda 1

3. Expand filesystem
resize2fs /dev/xvda1
df -h

How To Strip Windows Newlines in PHP

Author: , Posted on Wednesday, February 21st, 2018 at 12:20:45pm

$text = str_replace("\r", "", $text);

Dogs are Evil

Author: , Posted on Monday, February 12th, 2018 at 9:24:54am

mc-new-jersey-vicious-dog-law-20150604We need dog leash laws and owner accountability.

Dog bites are a problem. According to the American Veterinary Medical Association, 4.5 million Americans are bitten by dogs each year, and every day, nearly 1,000 individuals show up in hospital emergency rooms because of dog attacks. The annual cost of medical treatments for dog bites (including 27,000 reconstructive surgeries) is over $250,000,000, and insurance companies fork out $530 million dollars a year in dog bite claims. Then there are the 26 Americans who were killed by dogs last year.

Here’s what the researchers found:
• 25 percent of the participants had been bitten by a dog.
• Only one in three victims received medical attention.
• Men were nearly twice as likely to have been bitten as women.
• People who owned multiple dogs were three times more likely to be bitten than non-dog owners.
• Children are at higher risk: 44 percent of the bites occurred when the victim was younger than 16.
• In 55 percent of cases, the person had never before seen the dog that bit them.
• But the most interesting finding was related to personality: People with higher scores on the Big Five trait of emotional stability were 22% less likely to have been bitten by a dog than were individuals who were less emotionally stable.

How To Create and Restore an SVN Backup Dump File (.dmp)

Author: , Posted on Thursday, February 1st, 2018 at 2:38:48pm

Backup Compressed:
svnadmin dump /volumes/data/svn/yourRepo | gzip -9 > /volumes/data/backup/yourRepo.dmp.gz

Backup Uncompressed:
svnadmin dump /volumes/data/svn/yourRepo > /volumes/data/backup/yourRepo.dmp

Restore the Repo

Create a new SVN repository:
svnadmin create /volumes/data/svn/newRepo

Restore the dump file to the new repository:
svnadmin load /volumes/data/svn/newRepo < /volumes/data/backup/yourRepo.dmp

Just for good measure, here is how to checkout from a local repo:
svn co file:///volumes/data/svn/newRepo/the/path/to/what/you/want

How To Rename a Branch in Git Locally and Remotely

Author: , Posted on Wednesday, January 31st, 2018 at 6:56:50pm

Rename the old branch locally:
git branch -m oldBranch newBranch

Delete the old branch remotely:
git push origin :oldBranch

Push up the new branch, and make the local branch track with the new remote branch:
git push --set-upstream origin newBranch

How To Remove a Package Without the Dependencies (yum/rpm)

Author: , Posted on Tuesday, January 9th, 2018 at 9:59:48am

To remove a specific package without its dependencies use rpm:

rpm -qa | grep pecl
rpm -e --nodeps php55-pecl-jsonc php55-pecl-jsonc-devel
rpm -qa | grep pecl
rpm -e --nodeps php55-pecl-jsonc php55-pecl-jsonc-devel

As always, YMMV!

How To Fix MacOSX Yosemite 10.10 Memory Leaks via SMC and PRAM Resets

Author: , Posted on Thursday, January 4th, 2018 at 5:08:16pm

I was running out of memory constantly on Yosemite 10.10.5 and found the following article:
Edited and reposted without permission below…

  1. Disconnect any external or secondary monitors, if any is present. The video memory allocation leak can also happen if you have a system with an integrated card, like Intel, with no external monitors attached.
  2. Shut down your machine and enter Safe Mode (press shift once you turn on your computer again More Info: How to access Safe Mode)
  3. In safe mode, fix your disk permissions.
  4. From Safe Mode turn off your machine again and reset your System Management Controller (SMC). There are different methods, depending on machine, to do this. To know what method applies to yours read the following guide: Intel-based Macs: Resetting the System Management Controller (SMC)

    These are the steps I followed to reset the SMC for my iMac 5K:

    • Choose Apple menu > Shut Down.
    • After your Mac shuts down, unplug the power cord.
    • Wait 15 seconds.
    • Plug the power cord back in.
    • Wait 5 seconds, then press the power button again to turn on your Mac.
  5. Once your machine completes a full boot after resetting the SMC turn it off again and reset your PRAM (THIS IS THE MOST IMPORTANT STEP, BUT THE PREVIOUS ONES ARE ESSENTIAL FOR THIS ONE TO WORK). The PRAM stores small bits of data that indicate our Apple computer how to interact with the devices connected to it, including monitors and video cards. It also affects software.
  6. To reset it you should hold the OPTION, COMMAND, P and R keys in your keyboard immediately after turning on your machine again.You’ll hear the start up chime, continue pressing the keys until the machine boots and the chime starts A SECOND TIME, then release. IF YOUR YOSEMITE INSTALLATION LOCKS UP AT A BLACK SCREEN AFTER THIS, DONT PANIC! It’s normal, just turn off your computer and let it boot again.
  7. Once you have fully booted, reconnect your external displays.

More info about PRAM: OS X Mavericks: Reset your computer’s PRAM

How To Upgrade MySQL from 5.5 to 5.7 on CentOS/AWS Linux

Author: , Posted on Thursday, December 7th, 2017 at 10:28:05am

START: Server version: 5.5.54-log MySQL Community Server (GPL)
FINISH: Server version: 5.7.20-log MySQL Community Server (GPL)

mysql --execute="SET GLOBAL innodb_fast_shutdown=0;"
service mysqld stop
yum remove mysql mysql-*
yum install mysql57-devel mysql57-server mysql57-test
service mysqld start
mysql --execute="SET GLOBAL innodb_fast_shutdown=0;"
service mysqld stop
yum remove mysql mysql-*
yum install mysql57-devel mysql57-server mysql57-test
service mysqld start