Category Archives: TIL

TIP: Obliterate a file from GIT Repository (including history)

I did something stupid, and accidentally pushed some .pubxml files to a public GitHub repo that contained passwords.

I fixed up my .gitignore file, which took care of part of it, but if you viewed the history, the password were still exposed.

After much mucking about, this magical line, obliterated any trace of the file in my repo.

git filter-branch --index-filter "git rm --cached --ignore-unmatch *.pubxml" --prune-empty --tag-name-filter cat -- --all

Then this line, forced an update of the entire repo to GitHub, history and all.

git push origin --force --all

…that was a close call.

TIL: How to use adb to take a screenshot from Android

I was writing up another article and needed screen grabs from my device, and wanted a simple way to grab them, well, adb to the rescue!

adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png screenshot.png

It’s that easy.

The first line saves the screenshot on the device, the second pulls a file from the device to the local machine.

All of this assumes you have adb working and the drivers setup for your device. Which I will be showing how to do in a future post.

TIL: How easy it is to hack Windows.

Found this on a friends site (which I recommend you read as he posts some great sys admin tips and tricks!)

We watched it, then tried it out, and it worked. It takes about 2 minutes to change the password on an account and gain access to any windows computer.

The basic steps:

  1. When your computer is booting, reset it during the splash screen
  2. The prompt to repair appears, durin gthe repair there is an option to show the details in Notepad.exe
  3. You can use it’s Open/Save dialog to rename your sethc.exe (sticky keys) and replace it with a copy of cmd.exe
  4. Reboot
  5. On the login, hit shift 5 times, and get a cmd.exe window
  6. Use the ‘net’ commands to reset a local admin password
  7. Login and profit.

It’s way way way too easy. ¬†Looks like the only way to secure your machine is to encrypt the entire drive so a password is required just to start the boot process.

TIL: The subtle difference between Keypress and Keydown (aside from the obvious)

The other day at work, an innocuous question was posed…

So, in javascript ‘ (apostrophe) and right arrow have the same event key code. What am I supposed to do with that?

This did not seem right to me, but, sure enough, a js fiddle showed this to be true…almost (go to result tab, and hit different keyboard keys, it will show the character code).

What appeared to be the same code (if you hit apostrophe then an arrow) was actually just that the arrow didn’t register as a keypress, and you were still seeing the last keys code. However, this was only true in some browsers, IE and Chrome, Firefox I believe worked as one would expect.

Changing to a keydown event works, and shows the right arrow as 39, like it should.

Quirksmode clears up a bit of the confusion, and has a nice little tester at the bottom of the page.