Cannot connect to X server using docker on OS X - Part II - macos

I'm having the same difficulty as the one expressed here: Cannot connect to X server using docker on OSX
I'm very confused about the recommended instructions in the above link (I'm a novice on docker), and I'm hoping to get clarification about the following:
1) Do we "touch foo.foam" in a regular OS X terminal or do we touch it in the docker terminal; in my case, following "docker run -ti openfoamplus/of_v30plus_rhel66 /bin/bash"
2) You suggest running paraview (mine is the most recent) just like any other Mac app. So, basically, to double-click on paraview in the Applications folder? But when opening foo.foam via the Open Menu do we just open foo.foam and press the Apply button (it gives errors), or do we actually enter "paraview foo.foam" as per your instruction above? If the latter, then nothing really happens; I can't open anything!
3) If we're supposed to just open foo.foam, what do we do after that? How is docker even aware about any of this? Anyway, when I type paraview from within docker (after foo.foam is opened) I get the same X server error. I wouldn't expect otherwise!
Hopefully, you can provide a more step-by-step set of instructions?
Thanks in advance

#First steps with OpenFoam
You've successfully followed the instructions to run the cavity problem, but you run the final command paraview and the spits back an error about x server being unavailable.
here's what you do:
Download paraview natively to your mac. Then open up a terminal window and cd into the directory that you ran the cavity problem in. (note sure what directory? jump back to your docker shell and run echo $FOAM_RUN)
Once you're inside the cavity directory, make a new .foam file and open it with paraview.
$ touch foam.foam
$ open -a paraview foam.foam
Click on that Apply button - middle of the screen on the left. At the top screen you can then select things like pressure p and plot type surface, and step through the time dumps in the upper right (initially my mesh didn't render correctly, so I had to deselect internalMesh, apply, and then select it and apply again).
Not really sure what you're looking at? Here's the tutorial for the problem:
http://www.openfoam.com/documentation/user-guide/cavity.php#x5-40002.1

Related

How i can debug and use Arduino on Geany Ide?

i use Debian 11. i need to debugging and write for Arduino on Geany Ide. Can you help me please?
I have tried to install Arduino on Geany but it hasn't worked.I need to install also Geanypy but it hasn't worked.
just did the search before looking here ...
https://github.com/akienz99/geany-arduino
try it let me know how it goes.
If you followed akienz99's instructions:
have a .ino file loaded and active in Geany
menu>Build>set build commands. Click the top left input box if it is empty and input "Build and Upload" (without quotes).
Paste this into the next input box to the right (after making changes discussed below):
rm -r /tmp/arduino_build /tmp/arduino_cache;mkdir /tmp/arduino_build /tmp/arduino_cache;/usr/bin/arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/<USER>/.arduino15/packages -tools /home/<USER>/.arduino15/packages -libraries /home/<USER>/Arduino/libraries -fqbn=esp32:esp32:esp32doit-devkit-v1:FlashFreq=80,UploadSpeed=921600,DebugLevel=none -vid-pid=10C4_EA60 -ide-version=10819 -build-path /tmp/arduino_build -warnings=none -build-cache /tmp/arduino_cache -prefs=build.warn_data_percentage=75 %d/%f;python /usr/bin/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 /home/<USER>/.arduino15/packages/esp32/hardware/esp32/1.0.6/tools/partitions/boot_app0.bin 0x1000 /home/<USER>/.arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/bin/bootloader_dio_80m.bin 0x10000 /tmp/arduino_build/%f.bin 0x8000 /tmp/arduino_build/%f.partitions.bin
Click on the #2 far left input box if it is empty and type "Check syntax" or "Verify".
Paste this into the next input box to the right (after making changes discussed below):
rm -r /tmp/arduino_build /tmp/arduino_cache;mkdir /tmp/arduino_build;mkdir /tmp/arduino_cache;/usr/bin/arduino-builder -compile -logger=machine -hardware /usr/share/arduino/hardware -hardware /home/<USER>/.arduino15/packages -tools /home/<USER>/.arduino15/packages -libraries /home/<USER>/Arduino/libraries -fqbn=esp32:esp32:esp32doit-devkit-v1:FlashFreq=80,UploadSpeed=921600,DebugLevel=none -vid-pid=10C4_EA60 -ide-version=10819 -build-path /tmp/arduino_build -warnings=none -build-cache /tmp/arduino_cache -prefs=build.warn_data_percentage=75 %d/%f
It's important to note that I have /usr/bin/arduino-builder and /usr/bin/esptool.py in those commands, because my distro (Gentoo) has more recent versions. More than likely you won't, the easiest way to find out where arduino has put those commands on your computer is to run the arduino ide with a simple sketch, in file>preferences turn on verbose logging for both verify and compile and upload, and then run the verify and compile and upload commands, copying the verbose output and pasting it in a blank Geany document. You will find the path and indeed basically what I have presented here for the Geany commands.
Of course, you will also want to edit those commands and replace with details on the board you are using. I'm only using esp32 node32s/esp32doit-devkit-v1 lately, so those commands are set up for it, although I've got some Uno's around I'll surely use someday, so I'll have to come up with some method of switching them around easily, probably using bash files.
The commands are _long, but don't worry, Geany accepts them just fine and it all works perfectly, you will never have to start the arduino ide again. Also replace <USER> with your user directory name.
You can also add an external serial monitor, I like moserial. But I find starting it from within Geany more trouble than it's worth, I just start it standalone from my OS menu. If you do add it to build commands, I recommend adding it below the "Execute commands" near the bottom of the set build commands window. It pops up a little terminal window, I don't care for that, but it's better than adding it under "Arduino commands", as then it inhibits further compiles/uploads, Geany is waiting for response from it. This forces you to constantly open and close the serial monitor.
This should get you going.
The best method was worked out by this fellow https://gitlab.com/snouf/geany_plugin_arduino_ide
I used that for a couple of years until geanypy took a nosedive into oblivion about 3-4 years ago. It created menu items similar to the arduino ide, allowing you to choose board, baud rate, etc. on the fly. I'm hoping to get some time to try and convert his python plugin with cython/cythonize, making it a REAL Geany plugin.

How do I more easily copy and paste all the content in open file on remote server over ssh using tmux and iterm2?

Problem: I'm on a mac running a tmux server. Within my local tmux session, I connect to a remote linux server and open a file with vim. The text I want does not fit in a single pane without having to scroll. I want to grab the text in the file and copy and paste all of it to my local machine's memory.
Current Solution:
My current procedure for copying and pasting is very convoluted:
Zoom on the pane with ctl-b z
Turn off numbering in vim with :set nonumber
If the file or text I want does not fit in entire pane, I hit cmd - until the text is small enough to fit in the entire pane
Select text I need with my mouse while holding down the option key.
Hit cmd-c to copy to my local machine.
Better Solution?
My current solution is tedious and I'm tired of wondering if there is a better way. Anyone got a better solution?
Ideally, I'd love to be able to select the text with vim and have iterm2 somehow detect what has been selected in a pane and run a single keystroke to copy to my local machine. Not sure if that's possible or not.
OK, I went with the solution at github.com/wincent/clipper which works on my mac running macos 11.2.3.
The install instructions seem to be a little dated and are a bit confusing if you don't read them carefully. It took some trial and error to figure out how to get this working with vim on the remote machine:
Install with brew on your mac
Launch clipper as a daemon with brew services start clipper
On the remote machine, add the following line to your vimrc file:
nnoremap <leader>y :call system('nc -q 1 localhost 8377', #0)<CR>
Note: I had to add the -q 1 in there because I found vim would hang otherwise. The -q 1 arguments are not in the official documentation.
In your mac's ~/.ssh/config file:
Host *
RemoteForward 8377 localhost:8377
Make sure your remote server has port 8377 open!
On the remote machine, open a file with vim. Yank some lines. Then hit <leader>y.
Note: It took a while before it finally dawned on me that just <leader>y doesnt' work by itself. It's a two-step vim command process: 1) yank the text with a vim command 2) send the copied text to your mac with <leader>y.
That's it. My life feels so much better now. :)

adb: command not found after restarting OS X

I'm a bit of a noob at this, but every time I restart my machine and update OS X, I lose adb commands in terminal. I'm not sure how or why this happens or how to get them back aside from reinstalling adb tools, but I'm assuming there's a better way.
The adb tools need to be added to the paths so terminal searches the directory the tools are in.
Assuming you are using a bash terminal you edit or create .bash_profile-file that defines the paths to search, in the example below using the nano-editor:
nano ~/.bash_profile
Enter the path to the adb tools as follows:
export PATH=$PATH:/path/to/the/adb/tools
Save the file (CTRL-X, choose Yes on Save), close the terminal window and open up a new one to load the .bash_profile. This should solve your problem.

realpath couldn't resolve "/usr/bin/-perl" on Mac Terminal

I'm trying to install Tails on my Mac using this instruction guide (https://tails.boum.org/doc/first_steps/installation/manual/mac/index.en.html) and I've been successful up to step 4, sub-step 6 where it says "To run isohybrid.pl on the ISO image, execute the following command, replacing [tails.iso] with the path to the ISO image that you want to install."
Below is my terminal window. I have no idea what a majority of this means and this is actually my first time ever using terminal. I was able to figure out how to check my hidden bin folder through finder and I checked for -perl and I didn't see that file in there. I saw perl, perlbug, perldoc, etc. but no -perl. Also I'm confused as to if this command actually did something because the 'couldn't resolve' message and the '[Process completed]' message seem kind of contradictory. Anyway, if anyone could help me get unstuck, that would be great :)
Here is a screenshot of my terminal window: http://i.stack.imgur.com/Hmc8c.png

Open an ipython notebook via double-click on osx

I've downloaded a couple of ipython notebooks, and I'd like to open them in browser tabs without navigating to the directory I've downloaded them to and running ipython notebook notebook_name.ipynb.
I realize this probably means I'm lazy, but it seems like a common use case to me. Am I missing something obvious?
Use Pineapple application for opening and working on your IPython/Jupyter notebooks. It is pretty cool.
Update:
Now there is nteract, which is a new jupyter-like Desktop app. After installing it, make it the default app for opening .ipynb files. Then just double-click any notebook to start it right away.
I have found a nice way using Automator (Oct. 2017; with information from here):
open Automator and create a new Application
to add Run Shell Script drag and drop it from the list; might need these settings Shell: /bin/bash and Pass input: as arguments
insert the code below; if necessary adjust the path to jupyter
Code
#!/bin/sh
variable="'$1'"
the_script='tell application "terminal" to do script "/usr/local/bin/jupyter notebook '
osascript -e "${the_script}${variable}\""
save the script as an application (!)
try to open a .ipynb file and change the default app to this newly created one.
notes
This will open a terminal and run the jupyter notebook command, such that you can interrupt and stop the notebook-server from there.
Also note that you cannot test the app like that in Automator, but need to add the Get Specified Finder Items and insert some test notebook there (just for testing purposes).
As pointed out in the comments, there are two more notes:
To avoid spamming your browser history with notebooks, you can start your notebooks in incognito/private mode: Run jupyter notebook in incognito window
If you want to run notebooks in one server and don't mind an extra tool, Sachit Nagpal has pointed out (thank you), that one could also use nbopen. To use this workflow just replace "/usr/local/bin/jupyter notebook ' with "nbopen '. Any other tool should work alike.
pip install nbopen.
open Automator, create new Application
Drag'n drop Run Shell Script
Change Pass input to as arguments
Copy/paste this script:
variable="'$1'"
the_script='tell application "terminal" to do script "nbopen '
osascript -e "${the_script}${variable}\""
Save the new application to Applications directory as nb_open
Right click any ipynb file and select "Open with > Other" and select the nb_open in the Applications folder. Don't forget to check "Always Open With".
Select an ipynb file, get info (command + i) > Open With (select nb_open if not selected already) > Click Change All.... Done.
The application posted here worked pretty well for me: http://bioequity.org/2013/11/16/ipynbviewer/
You also need to download iTerm2, as described on that page.
Note that this doesn't work if there are spaces in the filename, but you can modify it so that it works with spaces in the filename. Control-click on the iPyNbViewer.app and select "Show package contents". Edit the file Contents/Resources/Scripts/main.scpt. Change three instances of "POSIX path" to "quoted form of POSIX path". Now it will work with spaces in the filename.
To set all of your .ipynb files to open with the app, you'll need to Get Info (command-I) on one of the files and select the iPyNbViewer app to open all .ipynb files.
It would be great if this was the default behavior of double-clicking on an iPython notebook file...
I came up with a way of doing it on Ubuntu. (It works for me but I can take no responsibility). It's explained here. In a nutshell, you need to create a new MIME type, then write a script that works as the app that launches them:
#!/bin/bash
netstat -tln |grep "8902"
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
ipython notebook / --no-browser --port=8902 &
sleep .5
fi
xdg-open http://localhost:8902/notebooks$1
This always opens the notebook server on port 8902, but first checks whether there is already a server running, and, if so, uses it.
Then you can use ubuntu tweak to select your script as a default application for the MIME type "IPython Notebook" you just created.
Not very elegant, but worth it, in my opinion.
PyCharm now supports Jupyter ipynb files:
which is from the documentation https://www.jetbrains.com/help/pycharm/editing-jupyter-notebook-files.html.
But I think this feature is only available in the Professional version now; hopefully it will be added to the Community version in the future.
Look at this link.
Put a bash script in the folder where you keep your ipython notebooks and simply double click it to open up a notebook instance. From the link above, the bash script has just:
path=$0 # path is path to this file
cd ${path%/*.*} # clip off the file name to get directory path and cd
ipython notebook --pylab inline
Finally, you need to chmod u+x the script to make it executable and you're done.
I have used the command line application 'nbopen' and put it in a Platypus wrapper to get drag'n drop and double click opening on Macos. 'nbopen' is downloadable using 'pip'
It works well when used as described above by DanHickstein.
Only problem with my code is that it requires the full path to the nbopen command. I know I should be able to use 'which nbopen' somehow but can't get it to work.
Heres my Platypus code:
#!/bin/bash
# Opens ipynb files in a Jupyter Notebook
# echo $1
# $1 is the path of the dropped file
/Users/robw/anaconda/bin/nbopen $1
# Based on an idea from
# https://www.quora.com/Is-there-a-straightforward-way-to-open-an-IPython-Notebook-in-Windows-by-double-clicking

Resources