Skip to content

How to compress only new files in a folder

In the shell using tar, you can compress only files newer then a specific date :)  Suuuuuper handy if you’re passing off files added to a large website to someone who already has an old version of that site.  So, pretty easy, you just run this command:

sudo tar -N ‘2016-12-01 00:00:00‘ -jcvf compressed.tar.bz2 folder

  • The Date (example date is December 1st 2016 midnight)
  • Location for output file
  • Folder to copy

How to convert a VirtulBox VM to a bootable drive

This is quite easy so I was surprised that I couldn’t find a walk-through anywhere…so here’s one :)  This is specifically for a VM of Ubuntu, so it’s possible there may be other hurdles in place for different operating systems.

Step 1

Create a VM normally in VirtualBox (or use an existing one), install the operating system, and add any programs or files you want to have readily available on the bootable disk.

Step 2

This is the tricky part, you can use Virtual Box to convert a vdi to an iso, but you have to do it from the terminal.  On my machine it wouldn’t work at all in windows default terminal, but I have Cygwin installed, and was able to use that.  You first need to cd into the directory where Virtual Box is installed, and run the following command.  The folder structure is specific to my machine and will most likely need to be changed on yours.

1
"/cygdrive/p/Programs/VirtualBox/VboxManage.exe" clonehd 'F:/Documents/Virtualbox/Ubuntu_2017/Ubuntu 2017.vdi' 'F:/Documents/Virtualbox/Ubuntu_2017.iso' --format RAW

More simply you need to run something like this:

1
VboxManage.exe clonehd 'vdi_location.vdi' 'where_generated_iso_will_be_location.iso' --format RAW

Step 3

Use rufus to install the ISO as a bootable image on your USB drive

And that’s about all you need to do!  Then you can take a carbon copy of your VM with you wherever you go :)  Great for travelling, which was my need.

Fastest way to search an object

Same deal as my previous post, I want to pin down the fastest method to use to search the parameter values of an object in Javascript using https://jsperf.com.  I found 4 different ways to receive the same result, this isn’t an exhaustive list but features some of the most common methods used for searching objects.

Between multiple tests findIndex and find did the best, but find was faster more often then findIndex.

obj_search

 

 

Fastest method for Javascript substring search

I have a mobile application that needs to search through a rather large array and I’m experiencing some optimization issues with it.  So, I decided to run some tests to see which function would be the fastest between indexOf, search, and includes.

I first tested all three with a static search value, search performed the best:

test1

But, with a variable, indexOf performed the best:

test2

I was able to perform these tests pretty easily using https://jsperf.com/ :)

nodejs with cygwin

I keep having to redo this, so I’m copying down the trick from this article here, so I can find in the future.  To get NPM and NodeJS to work in cygwin on windows, you just have the alias them using these commands in your .bash_profile:

1
2
alias npm="/cygdrive/p/Programs/nodejs/npm.cmd"
alias node="/cygdrive/p/Programs/nodejs/node.exe"