HNHacker News
TopNewBestAskShowJobs

apjana

661 karma · joined August 22, 2015

submissionscomments
apjana··on SIMD instructions
Not necessarily. There are implementations which don't even take advantage of 4/8 byte copying. We wanted to have something uniform. But yes, you are right with glibc or macOS.

Also, from the strncpy man page:

   strlcpy()
       Some systems (the BSDs, Solaris, and others) provide the following function:

           size_t strlcpy(char *dest, const char *src, size_t size);

       This function is similar to strncpy(), but it copies at most size-1 bytes to dest, always adds  a
       terminating  null  byte,  and  does  not pad the target with (further) null bytes.  This function
       fixes some of the problems of strcpy() and strncpy(), but the caller must still handle the possi‐
       bility of data loss if size is too small.  The return value of the function is the length of src,
       which allows truncation to be easily detected: if the return value is greater than  or  equal  to
       size,  truncation  occurred.  If loss of data matters, the caller must either check the arguments
       before the call, or test the function return value.  strlcpy() is not present in glibc and is not
       standardized by POSIX, but is available on Linux via the libbsd library.
apjana··on SIMD instructions
Adding nnn: https://github.com/jarun/nnn A terminal file manager.

It takes advantage of SIMD at -O3 level of optimization in it's custom string copy function: https://github.com/jarun/nnn/blob/bc7a81921ed974a408d4de2cbf...

The function is used extensively in the program.

apjana··on Power features in file manager nnn (Part 2)
This is the second installment of the 2-part series. We decided to have a distinct section in the Wiki for these type of features which may not be very obvious to the users from the rest of the documentation.
apjana··on Nnn file manager on Termux (Android)
A video demonstrating file manager nnn (https://github.com/jarun/nnn) running in the Termux (https://termux.com/) environment on Android and integrates with native Android apps.
apjana··on Underused Power-Features of Nnn
Covers the following:

  1. Pick files from multiple locations and pass to a command
  2. Pin a frequently visited a directory
  3. Filter filtered entries
  4. Mount and modify archives
  5. Hovered file path in $nnn
  6. Preview and edit files
  7. Prompt shortcuts
  8. Running custom commands with hotkeys
  9. Selection from multiple locations
  10. Create dirs or files with tree, duplicate anywhere
apjana··on File manager nnn v3.0 is released
The latest release has some interesting features like handling list of files as input, PCRE support, more readline-like bindings at the in-built prompt, lazy unmount, auto-proceed on open option (very handy when you are opening files one after another).

The keybind `e` to edit a file in `EDITOR` has been restored on multiple user requests.

Along with pre-built packages there's a static binary to download and run `nnn` without installing.

apjana··on Browser-independent bookmark manager buku v4.3 released
buku is a powerful bookmark manager written in Python3 and SQLite3. When I started writing it, I couldn't find a flexible command-line solution with a private, portable, merge-able database along with seamless GUI integration.

buku can auto-import bookmarks from your browser(s) or fetch the title and description of a bookmarked url from the web. You can use your favourite editor to compose and update bookmarks. With multiple search options, including regex and a deep scan mode (particularly for URLs), it can find any bookmark instantly. buku can look up the latest snapshot of a broken link on the Wayback Machine. There's an Easter egg to revisit random forgotten bookmarks too! Buku is too busy to track you: no hidden history, obsolete records, usage analytics or homing.

apjana··on File manager nnn v2.9 – simpler controls, smarter workflows
Thank you for the appreciation!

Why let the tool block you when you can use the time more productively? So we thought. ;)

apjana··on Broot – A new way to see and navigate directory trees
A new version of nnn is released - https://github.com/jarun/nnn/releases/tag/v2.9

It simplifies a lot of workflows and reduces the number of keys.

apjana··on File manager nnn v2.9 – simpler controls, smarter workflows
This release was driven by simplification. We wanted to make nnn much easier to use than the earlier versions. Also, it was about time we froze the keybinds. We also reduced the number by re-designing several workflows.

Users now have more control over plugin execution or commands run as plugins. We have combined some plugins too. Some were removed now that non-shell interpreted commands can be run as plugins directly.

The Wiki got richer too! Take a look around.

From the release notes:

  - user pain points addressed
    - all keybinds and options reviewed by the team and frozen (see #422)
    - reduced number of keybinds
    - greatly improved help screen readability
  - `nuke`: sample opener (CLI-only by default) and plugin
  - fast line redraws instead of full screen refresh
  - auto archive handling by extension (see config `NNN_ARCHIVE`)
  - Lead key simplified to bookmark key (<kbd>b</kbd> or <kbd>^/</kbd>)
  - single key to toggle order (<kbd>t</kbd> or <kbd>^T</kbd>)
  - plugins
    - `.cbcp`: copy selection to system clipboard (internal, program option `-x`)
    - `.ntfy`: show noti on cp, mv, rm completion (internal, program option `-x`)
    - `autojump`: navigate using autojump
    - `upload`: paste text files to http://ix.io, upload rest to https://file.io
    - all fuzzy plugins modified to support both `fzf` and `fzy`
  - more control on plugins
    - prefix `-` to skip directory refresh after running (cmd as) plugin
    - suffix `*` to skip confirmation after running cmd as plugin
  - indicate range selection mode with `*`
  - list keys at bookmark and plugin key prompts
  - visit to pinned dir like bookmarks (Bookmark key followed by <kbd>,</kbd>)
  - toggle executable (key <kbd>*</kbd>)
  - show mime along with file details
  - more special keys at empty filter prompt:
    - apply the last filter (<kbd>^L</kbd>)
    - toggle between string and regex (<kbd>/</kbd>)
    - toggle case-sensitivity (<kbd>:</kbd>)
  - retain filter on <kbd>Esc</kbd>, <kbd>Up</kbd>, <kbd>Down</kbd>
  - show filter details when filter is on
  - remove option to run filter as cmd on prompt key (can be disruptive)
  - program options
    - option `-x`: enable notis and copy selection to system clipboard
    - option `-g`: regex filters (string filter is default now)
    - option `-Q`: quit program without confirmation
    - option `-s`: load session
    - option `-n`: start in nav-as-you-type mode
    - option `-v`: version sort
    - option `-V`: show program version
    - option `-A`: disable dir auto-select
  - ISO 8601 compliant date in status bar
  - ported to Haiku OS
  - sort only filtered entries (to avoid directory refresh)
  - fix `getplugs` to install hidden files
  - fix several selection issues (see #400)
  - fix detail mode not restored on loading session
  - fix symlink to directory not auto-selected
  - fix regex error on partial regex patterns
  - fix symlink not shown if `stat(2)` on target fails
  - fix flags when spawning a CLI opener as default FM
  - fix issue with stat flag on Sun (no support for `dirent.d_type`)
  - fix current file in current context not saved correctly in session
  - signed source distribution on release
  - simplified debugging with line numbers in logs
apjana··on Broot – A new way to see and navigate directory trees
Yep, great ideas are always welcome! There's always room for improvement.
apjana··on Broot – A new way to see and navigate directory trees
Check out nnn - https://github.com/jarun/nnn

To install - brew install nnn

apjana··on Broot – A new way to see and navigate directory trees
> The ":s" verb for easily viewing the size of directories / files

It's the keybind "S" with nnn (or "A" for apparent usage). You can also use the same option ("-S") to open nnn in du mode.

> the overview of multiple directories at once

I explained the nnn design strategy in my other response

> the gitignore handling

This can be added but it changes the current generic way of handling directory entries

> There might be more, but I would have to spend more time with it

That would actually be a constructive data to improve nnn as well.

Thanks for the notes!

apjana··on Broot – A new way to see and navigate directory trees
No problem! Just wanted to get some insight and explain things as they are with nnn.
apjana··on Broot – A new way to see and navigate directory trees
> This has replaced nnn for me and solves so many devops headaches

Can you please elaborate? Is that specifically because nnn[1] doesn't show a complete overview of the filesystem or some other features are missing?

One of the guiding principles of nnn is to generate minimum disk IOs.

Reading through a complete volume on a stuffed microSD or SD card attached to a RaspberryPi to list the filesystem (even if compacted) and then supporting filesystem changes dynamically is resource-intensive. nnn development is driven by minimum resource availability and usage.

[1] https://github.com/jarun/nnn

apjana··on Broot – A new way to see and navigate directory trees
> Commom UI widgets are not prepared to deal with collections of widely varying sizes.

I don't think there is a standard widget other than what's implemented by each solution. Broot is one way of looking at a volume at the expense of lots of disk reads (for every file on the volume). Ranger does that at a single depth and that's a design choice in Miller's view. nnn doesn't prefer to read within directories unless explicitly requested and that's a design choice too. There's nothing good or bad about these other than a choice to the user to pick the one that fits his use case.

A user always has the liberty to concentrate only on the current directory, just know where he is in the filesystem from the file path and do a fuzzy search to find a file deep in the subtree when he needs to do so. As you might have noticed, even with Broot there's no simple way to list the files marked "unlisted" without navigating to the dir and expanding it. It's a nice program and is a solution to people who likes to see a snapshot of the filesystem in a glance. But would everyone be always interested in the contents of /etc, /run, /usr and /var as shown in one of the sample images?

apjana··on Broot – A new way to see and navigate directory trees
One of the guiding principles of nnn is minimum disk IOs so probably it's not comparable in this respect. Reading through a complete volume on a stuffed microSD or SD card attached to a RaspberryPi to list the filesystem and then supporting dynamic events may not be very simple. nnn development is driven by minimum resource availability and usage.
apjana··on Show HN: Keysniffer – an academic functional Linux kernel mode keylogger
`keysniffer` is a Linux kernel module to grab keys pressed in the keyboard, or a keylogger.

It's also an academic project for devs willing to learn Linux kernel module programming, with extensive comments, checkpatch.pl scanned code, standards-compliant Makefile and DKMS support.

`keysniffer` was initially written for the US keyboard (and conforming laptops). By default it shows human-readable strings for the keys pressed. Optionally, the keycode shift_mask pair can be printed in hex or decimal. You can lookup the keycodes in `/usr/include/linux/input-event-codes.h`.

The keypress logs are recorded in debugfs as long as the module is loaded.

apjana··on Show HN: bcal – Storage & general-purpose CLI calculator for programmers
`bcal` (Byte CALculator) is a REPL CLI utility for storage expression evaluation, unit conversion and address calculation. If you can't calculate the hex address offset for (512 - 16) MiB, or the value when the 43rd bit of a 64-bit address is set mentally, `bcal` is for you.

It has a `bc` mode for general-purpose numerical calculations. Alternatively, it can also invoke `calc` which works better with expressions involving multiple bases.

The latest version 2.2 is released today.

### Features

  - REPL and single execution modes
  - evaluate arithmetic expressions involving storage units
  - perform general purpose calculations (using bc or calc)
  - works with piped input or file redirections
  - convert to IEC/SI standard data storage units
  - interactive mode with the last valid result stored for reuse
  - show the address in bytes
  - show address as LBA:OFFSET
  - convert CHS to LBA and vice versa
  - base conversion to binary, decimal and hex 
  - custom sector size, max heads/cylinder and max sectors/track
  - minimal dependencies
apjana··on Ask HN: Which project does not have any good open-source alternatives?
nnn with dvtm - https://github.com/jarun/nnn

Even without dvtm you can have mutiple contexts. nnn is extremely fast with tons of features. Many plugins are available already and it's easy to add new ones.

apjana··on Terminal FM nnn adds sessions, cloud mounts and several other exciting features
Some of the cool features available in v2.8 are:

  - sessions support (start where you left `nnn`)
  - `rclone` integration (mount S3, box, dropbox and what not!)
  - mount archives and view/modify without extracting
  - run custom commands like plugins (short and sweet commands a key away!)
  - copy, move as (edit filenames in editor before copy and move)
  - `nnn` will now work with the most minimal `xargs`flavour
  - keybind collision checker (for those who prefer custom keybinds)
  - allow plugins to control the active directory of `nnn`
  - several new plugins
  - better support for editing files in detached mode
  - and lot more...
The size remains ~65KB still!
apjana··on I am no longer able to use Google with Lynx
Also ddgr: https://github.com/jarun/ddgr

Same author, no tracking, works over Tor.

apjana··on I am no longer able to use Google with Lynx
There's a patch over v3.9 that works with the new layout: https://github.com/jarun/googler/issues/306

Hopefully we'll have a PR merged soon.

apjana··on DuckDuckGo Terminal Interface
Yes, you can open the results in FF.
apjana··on An Illustrated Guide to Useful Command Line Tools
+1 for nnn!
apjana··on An Illustrated Guide to Useful Command Line Tools
fzy is cool and probably underrated. It's the preferred fuzzy utility for file manager nnn too.
apjana··on nnn file manager on Termux (Android)
A video to demonstrate how `nnn` (https://github.com/jarun/nnn) integrates with native Android apps and the vim editor on Termux.

Device details:

    Android v8.1
    Octa core (2 GHz, Quad core, Cortex A73 + 2 GHz, Quad core, Cortex A53) processor
    6 GB RAM
apjana··on File manager nnn v2.5 released with many plugins, mouse support, sshfs and more
`nnn` is a lean and fast file manager, disk usage analyzer, fuzzy app launcher and batch file renamer.

Homepage: https://github.com/jarun/nnn

### New in v2.5

  - [plugin](https://github.com/jarun/nnn/tree/master/plugins) support. 19 plugins added. Some are:
    - pdfview: view a PDF in pager
    - nmount: (un)mount a storage device
    - ndiff: file and directory diff for selection
    - hexview: view a file in hex
    - imgresize: batch resize images to desktop resolution
    - ipinfo: check your IP address and whois information
    - transfer: upload a file to transfer.in
    - pastebin: paste the contents of a text file to paste.ubuntu.com
    - boom: play random music from a directory
    - nwal: set an image as wallpaper using nitrogen
    - pywal: set selected image as wallpaper, change terminal color scheme
    - getplugs: update plugins
  - SSHFS support
  - support `bsdtar`, simplify `patool` integration
  - native batch rename support (`vidir` dependency dropped)
  - mouse support
  - new location for config files - `~/.config/nnn`
    - plugin dir location: `~/.config/nnn/plugins`
    - selection file `.nnncp` is now `~/.config/nnn/.selection`
  - support [configuration](https://github.com/jarun/nnn/wiki/nnn-as-default-file-manager) as the default file manager
  - per-context detail/light mode
  - case-insensitive version compare
  - shortcut to visit `/` - <kbd>`</kbd> (backtick)
  - vim-like scrolloff support
  - `^D` & `^U`: scroll half page, `PgDn` & `PdUp`: scroll full page
  - fix selection across contexts
  - recognize `Home` and `End` keys at prompt for editing
  - fix broken program option `-b`
  - POSIX-compliant user-scripts (wherever possible)
  - `NNN_SCRIPT` is retired (replaced by plugins)
apjana··on Performance of nnn vs. ls

    Timing 500000 iterations
    F time 0.006025
    I time 0.011848
Expected, right? First you called `coolsize_i(lrand48())` and then `coolsize_f(lrand48())`? In your results F should be I and I should be F.

In all your tests the F version is slower, as per my expectation.

apjana··on Performance of nnn vs. ls
Yes, even I ran the tests and noticed printing the double in snprintf() is the bottleneck Any idea how we can do that faster and we get the format we need in `nnn`?
← PreviousPage 3 of 10Next →