How To Move in vim Using the Keyboard

Author: , Posted on Wednesday, March 21st, 2018 at 12:55:29pm

h move one character left
j move one row down
k move one row up
l move one character right
w move to beginning of next word
b move to previous beginning of word
e move to end of word
W move to beginning of next word after a whitespace
B move to beginning of previous word before a whitespace
E move to end of word before a whitespace
All the above movements can be preceded by a count; e.g. 4j moves down 4 lines.

0 move to beginning of line
$ move to end of line
_ move to first non-blank character of the line
g_ move to last non-blank character of the line

gg move to first line
G move to last line
ngg move to n'th line of file (n is a number; 12gg moves to line 12)
nG move to n'th line of file (n is a number; 12G moves to line 12)
H move to top of screen
M move to middle of screen
L move to bottom of screen

zz scroll the line with the cursor to the center of the screen
zt scroll the line with the cursor to the top
zb scroll the line with the cursor to the bottom

Ctrl-D move half-page down
Ctrl-U move half-page up
Ctrl-B page up
Ctrl-F page down
Ctrl-O jump to last (older) cursor position
Ctrl-I jump to next cursor position (after Ctrl-O)
Ctrl-Y move view pane up
Ctrl-E move view pane down

n next matching search pattern
N previous matching search pattern
* next whole word under cursor
# previous whole word under cursor
g* next matching search (not whole word) pattern under cursor
g# previous matching search (not whole word) pattern under cursor
gd go to definition/first occurrence of the word under cursor
% jump to matching bracket { } [ ] ( )

fX to next 'X' after cursor, in the same line (X is any character)
FX to previous 'X' before cursor (f and F put the cursor on X)
tX til next 'X' (similar to above, but cursor is before X)
TX til previous 'X'
; repeat above, in same direction
, repeat above, in reverse direction

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