A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

All the homebrew packages I've installed on Mac OSX

I've used `brew install ....` many times, but now I'm regretting it because:

  • `brew update` takes so incredibly long to run, and downloads lots of unnecessary git history
  • `/usr/local/Cellar` is 3.8Gb big and I'm short on disk space
List of brew installed apps, in date order:
  • redis@4.0
  • watch
  • tree
  • dnsmasq
  • libunistring
  • libxmlsec1
  • xmlsec1
  • ack
  • putty
  • cmatrix
  • the_silver_searcher
  • ag
  • youtube-dl
  • elasticsearch@6.7
  • vbindiff
  • libpng
  • ilmbase
  • oniguruma
  • jq
  • telnet
  • gifsicle
  • fontconfig
  • tidy-html5
  • minio
  • gcc@4.9
  • autoenv # bugged: breaks "cd -"
  • direnv
  • maven@3.6
  • htop-osx
  • htop
  • xvid
  • npm
  • node@14
  • lsd
  • id3v2
  • nghttp2
  • gnutls
  • sphinx-doc
  • protobuf@3.17
  • markdown
  • postgres@13
  • ruby
  • httrack
  • chafa
  • wget
  • python@3.7
  • python2
  • coreutils
  • ctags-exuberant
  • ctags

Improving Perl's Test2 documentation and using the metacpan docker image

#fixallthethings #tooling #fail on Mac OSX 13.6 High Sierra

Folding@Home FAHClient on Mac OSX

Mac [23:49  ~$] pkgutil --file-info /usr/local/bin/FAHClient
volume: /
path: /usr/local/bin/FAHClient
pkgid: org.foldingathome.fahclient.pkg
pkg-version: 7.5.1
install-time: 1585049394
uid: 0
gid: 0
mode: 755



Mac [23:50  ~$] pkgutil --files org.foldingathome.fahclient.pkg
Applications
Applications/Folding@home
Applications/Folding@home/Web Control.url
Library
Library/LaunchDaemons
Library/LaunchDaemons/org.foldingathome.fahclient.plist
usr
usr/local
usr/local/bin
usr/local/bin/FAHClient
usr/local/bin/FAHCoreWrapper

How to install libxmlsec1 via Alien::LibXMLSec on Mac OSX

  1. Make sure openssl is installed
  2. Download Alien::LibXMLSec (it's not on CPAN)
  3. Unzip it & change to dir
  4. perl Makefile.PL
  5. PKG_CONFIG_PATH=/usr/local/Cellar/openssl@1.1/1.1.1k/lib/pkgconfig make
  6. make
  7. make install
Note: To get the Makefile.PL to run (i.e. step 3½), you may also need to:
  • git clone Alien::Build from its git repo
  • do a `dzil build` on that
  • then set the PERL5LIB to point to the built instance of Alien::Build
  • ...and also make sure its deps are in PERL5LIB.

How to install DBD::Pg Perl module on Mac OSX

Make sure `pg_config` is in your path, and that's it! DBD::Pg will build normally.

Disable Mac Spotlight (mds_stores) because it uses too much CPU and disk space

# Disable spotlight
sudo mdutil -a -i off
# Restart the Mac

# I reclaimed 3.5Gb of disk space

# Delete database (was only 12K for me)
sudo rm -rf /.Spotlight-V100/

(source)

How to copy off images from Chrome's cache (on Mac)

How to find Chrome cache on Mac

export YOU=your_username
export PROFILE=Default

mkdir ~/chrome_images
cp /Users/$YOU/Library/Caches/Google/Chrome/$PROFILE/Cache/* ~/chrome_images/
for k in `/bin/ls`; do mv $k $k.jpg; done # rename all files to jpg

open ~/chrome_images

# Now browse the image folder and find the images you want

# More sophisticated renaming example:

if [[ `file $filename | grep JPEG` ]]; then mv $filename{,.jpg} ; fi

Mac clients for AWS RedShift

JetBrains just released DataGrip ( JetBrains DataGrip: Your Swiss Army Knife for Databases and SQL ). I've been using it full time during the EAP (aka "beta"). It's expensive ($90/yr or $9/mth) but very, very good. Never loses your work. Starts up right where it left off. Dark and light themes. DB specific syntax highlighting. Good stuff.

Before that I was using Navicat Premium Essentials. I got it for ~$20. It's now ~$150 which is too much given it's limited functionality and spotty reliability IMO.
re:dash is overly simple for serious use IMO. Edit: We're actually using this now. It's more of service than an SQL client. It allows casual users (e.g. not full time analysts) to run queries without any setup. Great for centralised dashboards and sharing queries. Try this before you commit to something like Periscope, Looker or Mode.
Portico (was PG Commander) looks interesting but I (personally) need to work with multiple database flavors so it's a non-starter.
SQuirreL and SQL Workbench/J are both pretty crunchy and old feeling Java apps. If you've been on a Mac for a while they will make your eyes bleed.
There is also Toad on the Mac App Store. The screenshots look Mac native but it's pretty crunchy and unpleasant. It feels like going back in time.
Update 2016–09–02: I would suggest that you also look into the “code notebook” applications that are available now, e.g. Jupyter, Zeppelin, and Beaker. You may well find these tools more useful unless you’re a full time DBA. We have replaced Re:Dash with Zeppelin internally.


How OG fixed his Mac AGAIN

`for i in ../opt/openssl/lib/lib*; do ln -vs $i .; done`

and also installing *pkg-config*

and also deleting a local directory from `~/`

Mac top

On a Mac, sort top output by %CPU, descending:

top -o -cpu

URLs open in Safari instead of Chrome from Mac OSX Terminal

To set the correct default browser on OSX, go to System preferences | General | Default web browser.

If the default browser is correct but Terminal is still not behaving correctly, then change the default browser, and change it back again.

TIOA-TIOA FTW

(source)

Catch runaway processes on Mac

#!/bin/sh

# kill runaway processes at 100% CPU usage (Mac OSX)
export PNAME=$1
if [[ ! $PNAME ]]
then
    echo "usage: runaways.sh [process name]"
    exit
fi

export PPERCENT='100.0'
SECONDS_TO_TEST=20
THRESHOLD=15

SECONDS_RUNAWAY=$(top -l $SECONDS_TO_TEST | perl -lne'BEGIN{$c=0};/$ENV{PNAME}\s+$ENV{PPERCENT}\%/ && do { $c++ };END{print$c}');
if [[ $SECONDS_RUNAWAY -gt $THRESHOLD ]]
then
    echo "killing $PNAME at $PPERCENT"%...
    PID=$(top -o cpu -l 2 | perl -lne'/$ENV{PNAME}\s+$ENV{PPERCENT}\%/ && print $1')
    if [[ $PID ]]
    then
        echo "Killing $PNAME"
        kill -9 $PID
    else
        echo "$PNAME does not exceed the threshold for a runaway"
    fi
else
    echo "$PNAME is not runaway"
fi

Subversion on a Mac 10.4 (Tiger), behind a firewall

The Subversion project recommends:
  • THIS ONE WORKS: MacPorts - has a .dmg installer for 10.4 
    • need to set environment variable http_proxy if behind a firewall
    • then the sudo port -v selfupdate command
    • then do sudo port install subversion 
    • Warning: The installed version of Xcode (2.3) is known to cause problems. Version 2.5 or later is recommended on Mac OS X 10.4. Download Xcode tools.
  • Fink - wouldn't install for me, saying "Cannot perform symlink test on this volume because of a permissions problem". Running "Repair Disk Permissions" utility as recommended doesn't help at all.
  • Apple's Developer Tools - I don't think it's on the CD. Couldn't find a list of apps anywhere. When I tried, it installed a lot of stuff but I couldn't see svn anywhere.
  • OpenCollabNet - ?

    Remote file browsing

    • Mount a remote filesystem via SFTP
      • (Mac): http://pqrs.org/macosx/sshfs/
      • (Ubuntu): Use software centre
      • GUI
        • Try http://sshfs-gui.darwinports.com/
        • or Mac ports: sudo port install sshfs-gui
      • To start: sshfs hostname: mountpoint
      • To stop: fusermount -u mountpoint
    • Target Management (Remote file browsing in Eclipse via SSH): http://www.eclipse.org/dsdp/tm/

    FTP client for Linux and Mac

    Filezilla is brilliant, and extremely fast.

    Edit text files on remote linux servers

    UNTESTED:

    > I've never managed to figure out how to rig up editors to edit
    > files on remote servers.

    On the server, put this in smb.conf

    [homes]
    comment = Home Directories
    hide dot files = yes
    read only = No
    browseable = yes


    Then in the finder/windows explorer connect to 'smb://hostname/' . Then make an alias to it on your desktop.

    Alternatively, TextWrangler on the Mac has an ftp/sftp browser.

    http://www.barebones.com/products/TextWrangler/

    Taking Screenshots in Mac OS X

    http://guides.macrumors.com/Taking_Screenshots_in_Mac_OS_X

    Shortcuts

    * Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop
    * Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop
    * Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop
    * Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard
    * Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard
    * Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard

    In Leopard, the following keys can be held down while selecting an area (via Command-Shift-4 or Command-Control-Shift-4):

    * Space, to lock the size of the selected region and instead move it when the mouse moves
    * Shift, to resize only one edge of the selected region
    * Option, to resize the selected region with its center as the anchor point

    Toggle visibility of non-printable characters in Mac Word

    Preferences | View | Nonprinting characters -> tick boxes