Category Archives: Distros

Mount HFS+ as R/W without a MacOS

If you created a usb flash drive using MacOS, chances are you might have an HFS+ (journaled) file system device in your hands.

NOTE: If you do have a Mac sitting around, try this before.

In case you do not have access to a Mac, you may have to tweak a little to get your device working normally.

When you try to use your usb stick in Linux, you will have it mounted as a Read Only file system.

/dev/sdb3 on /media/dbkreling/dbkusb type hfsplus (ro,nosuid,nodev,uhelper=udisks2)

A filesystem check (fsck) did not work for me:

$ sudo fsck /dev/sdb3
fsck from util-linux 2.20.1
fsck: fsck.hfsplus: not found
fsck: error 2 while executing fsck.hfsplus for /dev/sdb3

Let’s install it then. The name of the package is hfsprogs:

$ sudo apt-get install hfsprogs

Preparing to unpack .../hfsprogs_332.25-11_amd64.deb ...
Unpacking hfsprogs (332.25-11) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up hfsprogs (332.25-11) ...

Now let’s try fsck again:

$ sudo fsck -f /dev/sdb3
fsck from util-linux 2.20.1
** /dev/sdb3
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume dbkusb appears to be OK.

Nice! Making progress… Then create a mounting point for it, other than the default one (without this step, I could not make it work, so make sure you do it):

$ mkdir /mnt/usb

Make sure the flash drive is unmounted and remount it at the new mount point, forcing r/w mode:

$ sudo umount /dev/sdb3
$ sudo mount -t hfsplus -o force,rw /dev/sdb3 /mnt/usb/
$ mount
....
/dev/sdb3 on /mnt/usb type hfsplus (rw,force)

Cheers!

References:

https://askubuntu.com/q/332315

https://superuser.com/a/84447

Advertisements

Git: two awesome quick commands

Find branches the commit is on

git branch --contains <commit #>

Sample output:

Screen Shot 2017-10-17 at 10.18.41 PM10-17-17

fetch_weather, implement_axios and master all have the commit # 3dea5b6

Ref.: https://stackoverflow.com/questions/2706797/finding-what-branch-a-git-commit-came-from

Show all branches with unmerged commits to <branch>

git branch -a --no-merged <branch>

Sample output:

Screen Shot 2017-10-17 at 10.22.39 PM10-17-17

remotes/origin/error_handler has not yet been merged into master

Ref.: https://stackoverflow.com/questions/3600728/git-list-all-unmerged-changes-in-git

Happy git work!

Cheers!

Git history (log) of a line

This is the first answer of this question on Stack Overflow, about how to see the history of a line of code on git.

Since git 1.8.4, there is a more direct way to answer your question.

Assuming that line 110 is the line saying var identifier = "SOME_IDENTIFIER";, then do this:

git log -L110,110:/lib/client.js

This will return every commit which touched that line of code.

[Git Documentation (see the “-L” command line paramenter)]

 

Cheers!

Fast search your project with ag – the silver searcher

“Ag” is a powerful search tool that can come in handy in many situations. Use it to replace your grep searches.

NOTE: some exploration is still to be made, so if you are a pro, share your knowledge with the peasants 😉

Ubuntu 16:
$ sudo apt install silversearcher-ag

Fedora 26:
$ sudo dnf install the_silver_search

Usage:

$ ag -h

Usage: ag [FILE-TYPE] [OPTIONS] PATTERN [PATH]

Recursively search for PATTERN in PATH.
 Like grep or ack, but faster.

Example:
 ag -i foo /bar/

If you give it a try, let us know

Cheers!

Git: find what commit inserted such file

I was in need of finding the commit that added a specific file in my project and “I got lucky” on Google:

Say we need the commit that introduced foo.js in the project, the command would be:

$ git log --diff-filter=A -- foo.js

And a super nice alias would be:

$ git config --global alias.whatadded 'log --diff-filter=A --'

and to use it:

$ git whatadded filename

That’s it.

Reference: https://stackoverflow.com/questions/11533199/find-commit-where-file-was-added