Bluetooth speakers can easily be used with the Raspberry Pi and other Linux single-board embedded computers to wirelessly play sound.
After
connecting to Bluetooth device from Linux terminal,
setup BlueZ like:
apt install bluez
Then setup Alsa or Pulseaudio to use the Bluetooth audio device, whether by GUI or command line.
We develop and deploy data collection from remote, inaccessible sites located around the world.
Thus we need to have highly-reliable methods of remote control.
This is accomplished in part by Intel vPro enabled computers, allowing remote power down, reboot, and even reinstall the operating system remotely from a HTTP vPro internal webserver.
Remote PC control checklist:
Intel vPro motherboard
Certificates to control vPro (don’t rely on passwords for full PC control!)
Clonezilla DVD in DVD drive
Clonezilla HDD image on Blu-ray in drive or USB HDD / flash drive
Hardware Firewall to not expose vPro ports to outside world.
Commercial remote desktop: SSH port forwarding and RDP, but what about those who want to use LogMeIn or the like?
Pros:
Commercial remote desktop services such as LogMeIn are typically more secure on a Windows PC than just leaving port 3389 open to the internet.
LogMeIn has convenient apps for smartphones and from a web browser
Cons:
The downsides of LogMeIn-type commercial services have philosophical and practical aspects.
Commercial services typically use proprietary (non-open-source) technologies for the central server and/or securing the connection. Open source choices are using perhaps the same technology but open to world-wide security reviewers.
The convenience of commercial services (centralized server making the connections) is seen by some as a weakness, since it could have unknown hackers as employees, could shut down their server, raise prices, etc.
Free alternatives:
SSH → RDP: Cygwin OpenSSH server SSH port forward port 3389
conda and pip are not merely two different ways to install Python packages.
Conda can install compilers such as gfortran.
Here are a few factors on where conda or pip have respective advantages.
This article defines “cross-platform”: working on Linux, macOS and Windows
Ease of install: Python
wheels
greatly ease end-user install of libraries requiring compilation without the end-user needing a compiler.
For example, high-performance Fortran, C and/or C++ code can be imported as a Python module, compiled beforehand and downloaded automatically.
However, major packages like
SciPy released cross-platform wheels
only in late 2017 (SciPy 1.0.0).
This means until 2017, easily installable, pre-compiled SciPy was not universal–some users would have to have Fortran, C and C++ compilers installed.
For a large subset of Python users, compiling software libraries is not intuitive and end users disliked waiting 10 minutes for SciPy to compile itself.
A core design reason behind conda is excellent conflict resolution, so I often type conda install when I want to install something complicated like Spyder.
The first-class conflict resolution of conda is matched by excellent virtual environment management.
conda env list
lists all the environments installed.
This allows you to safely try out complicated programs like Mayavi with lots of prerequisite packages.
Instead of ripping out the latest libraries you have, create Python environments with
conda create
High performance MKL Python libraries:
Python Intel MKL FFT benchmark.
pip install scipy
downloads and immediately makes available precompiled Fortran, C, C++ libraries within SciPy.
Python wheels do not obviate Conda’s usefulness!
One of the key advantages of using conda-installed packages are the free
high-performanceAnaconda MKL libraries,
freely available since February 2016 for:
Typically the terminal/command prompt is 80 or 100 characters wide.
The advantage of this method is that previous information is not scrolled off the screen.
One common use for this method is terminal text progress indicators.
Using special characters, pseudo-graphical dynamic terminal displays are also possible, or use Python
curses.
Here’s an example:
fromtimeimport sleep
N=12for i inrange(N):
sleep(0.5)
print(f"{i/N*100:.1f} %", end="\r")
One cannot create an actual new terminal session windows from curses.
curses.newwin() “new window” is inside the “screen”, which is the existing Terminal.
In data science we often deal with messy, heterogeneous data and file types too.
Python Pandas is a very powerful data science tool.
A simple but not infrequent mistake is using the wrong Pandas function to read data, that is, using read_excel to read CSV data or read_csv to read Excel spreadsheet data.
Note: Pandas cannot read ODS OpenDocument formats, so for those using LibreOffice/OpenOffice, convert ODS data to XLSX first.
SCP does not have an option to exclude files while copying remote files over SSH.
This is a problem when you have Git-managed code you’ve modified on say:
offline computer
HPC, and don’t want to put your Git host credentials on the HPC
If you just use scp -r, you’ll also overwrite the .git directory which can destroy work done on this or other branches.
We want to just copy the code files, NOT the .git tree.
Note exclusion under bin/ of the repository.
The HPC probably runs a different Linux distro and the compilation is optimized for a different CPU, so the HPC binaries wouldn’t generally be useful elsewhere.
The Fortran 2003
standard
constitutes a strong foundation of “modern Fortran”.
Modern Fortran (Fortran ≥ 2003) is so different in capabilities and coding style from Fortran 77 as to be a distinct, highly backward compatible language.
Almost all of Fortran 95 was incorporated into Fortran 2003, except for a few obscure little used and confusing features deprecated and already unsupported by some popular compilers.
Writing to console effectively: write(*,*) grew out of non-standard use of Fortran 66’s write statement that was introduced for device-independent sequential I/O.
Although write(*,*) became part of Fortran 77 for printing to console standard output, the Fortran 77 print command is more concise and more importantly visually distinct.
That is, where the full versatility of the write command is not needed, print should be used to help make those cases where write is needed more distinct.
Assembly language comparison: print *,'hi' and write(*,*) 'hi' are IDENTICAL in assembly, within modern compilers as it should be.
In general, disassemble Fortran executables with:
Fortran 2003 finally settled the five-decade old ambiguity over console I/O with the intrinsic iso_fortran_env module, which is often invoked at the top of a Fortran module like:
The => operators are here for renaming (they have other meanings for other Fortran statements).
It’s not necessary to rename, but it’s convenient for the popularly used names for these console facilities.
Recommendation: routine console printing:
print*,'Hello text'
For advanced console printing, whether to output errors, use non-advancing text, or toggle between log files and printing to console, use write(stdout,*) or the like.
Example: print to stdout console if output filename not specified
use,intrinsic::iso_fortran_env,only:stdout=>output_unitimplicitnone(type,external)character(:),allocatable::fninteger::i,u,Lcallget_command_argument(1,length=L,status=i)if(i/=0)error stop"first command argument not available"allocate(character(L)::fn)callget_command_argument(1,fn)if(i==0)thenprint'(a)','writing to '//fnopen(newunit=u,file=fn,form='formatted')elseu=stdoutendifi=3! test data
write(u,*)i,i**2,i**3if(u/=stdout)close(u)! closing stdout can disable text console output, and writes to file `fort.6` in gfortran
print*,'goodbye'! end program implies closing all file units, but here we close in case you'd use in subprogram (procedure), where the file reference would persist.
endprogram
Polymorphism is a part of generic programming enabled by Fortran 2003.
Typically one should encapsulate procedures in modules, even when the whole program is contained in a single file.
Example: addtwo() automatically selects the correct type thanks to the interface block.
modulefuncsuse,intrinsic::iso_fortran_env,only:sp=>real32,dp=>real64implicitnone(type,external)!! takes affect for all procedures within module
interfaceaddtwoprocedureaddtwo_s,addtwo_d,addtwo_iendinterfaceaddtwocontainselementalreal(sp)functionaddtwo_s(x)result(y)real(sp),intent(in)::xy=x+2endfunctionaddtwo_selementalreal(dp)functionaddtwo_d(x)result(y)real(dp),intent(in)::xy=x+2endfunctionaddtwo_delementalintegerfunctionaddtwo_i(x)result(y)integer,intent(in)::xy=x+2endfunctionaddtwo_iendmodulefuncsprogramtest2usefuncsimplicitnone(type,external)real(sp)::twos=2._spreal(dp)::twod=2._dpinteger::twoi=2print*,addtwo(twos),addtwo(twod),addtwo(twoi)endprogram