macos
Variables overwriting text problem with “echo” in Bash
A wild guess here: you are extracting the IP variable from a .txt file — if that’s a Windows file, or is encoded Windows-style, lines end with \r\n. You take the newline away, but what if there’s a \r in it that’s making you go back to the beginning of the line? Quick dirty fix … Read more
Why does the Mac ABI require 16-byte stack alignment for x86-32?
From “IntelĀ®64 and IA-32 Architectures Optimization Reference Manual”, section 4.4.2: “For best performance, the Streaming SIMD Extensions and Streaming SIMD Extensions 2 require their memory operands to be aligned to 16-byte boundaries. Unaligned data can cause significant performance penalties compared to aligned data.” From Appendix D: “It is important to ensure that the stack frame … Read more
How to save PNG file from NSImage (retina issues)
If you have an NSImage and want to save it as an image file to the filesystem, you should never use lockFocus! lockFocus creates a new image which is determined for getting shown an the screen and nothing else. Therefore lockFocus uses the properties of the screen: 72 dpi for normal screens and 144 dpi … Read more
OS X / Linux: pipe into two processes?
You can do this with tee and process substitution. program1 | tee >(program2) >(program3) The output of program1 will be piped to whatever is inside ( ), in this case program2 and program3.
How to run the Homebrew installer under Rosetta 2 on M1 Macbook
Got an answer from a developer in the Homebrew github https://github.com/Homebrew/brew/issues/9173 arch -x86_64 /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)” Use this to install packages: arch -x86_64 brew install <package> If you have not yet installed Rosetta 2 to emulate Intel CPUs on ARM Macs, you will get the error arch: posix_spawnp: /bin/bash: Bad CPU type in … Read more
editing PATH variable on mac [closed]
Open and edit /etc/paths using any text editor. $ sudo vi /etc/paths (editing text files with vi) Note: each entry is separated by a new line /usr/local/bin /usr/bin /bin /usr/sbin /sbin Save and close the file. Then restart your terminal.
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)
For what it’s worth, before installing Homebrew you will need to install Rosetta2 emulator for the new ARM silicon (M1 chip). I just installed Rosetta2 via terminal using: /usr/sbin/softwareupdate –install-rosetta –agree-to-license This will install rosetta2 with no extra button clicks. After installing Rosetta2 above you can then use the Homebrew cmd and install Homebrew for … Read more
List of macOS text editors and code editors [closed]
I thought TextMate was everyone’s favourite. I haven’t met a programmer using a Mac who is not using TextMate.
Installing R on Mac – Warning messages: Setting LC_CTYPE failed, using “C”
Open Terminal Write or paste in: defaults write org.R-project.R force.LANG en_US.UTF-8 Close Terminal (including any RStudio window) Start R For someone runs R in a docker environment (under root), try to run R with below command, LC_ALL=C.UTF-8 R # instead of just `R`