Monday, March 6, 2017
How to store dupont cables in a box
Just to share, I eventually found a nice way to store DuPont wire cables efficiently (aka jump wires, or breadboard jumper cables).
I re-shaped the movable separators in a super low cost, floppy box I bought on the internet.
I should have taken a picture of the former mess. The cables would never stay in place before I had a chance to close the drawer!
I re-shaped the movable separators in a super low cost, floppy box I bought on the internet.
I should have taken a picture of the former mess. The cables would never stay in place before I had a chance to close the drawer!
Thursday, February 9, 2017
Use sshfs to upload to a remote www-data apache folder with working user rights
A client of mine is heavily using Samba (workgroup) from their Windows PC. I used to add samba shares or symbolic links within existing shares so they could access the data folder of different webservices hosted on the server. So far so good.
Recently, they purchased a secondary server to off-load part of the existing services, but they would like to keep the convenient file access through Samba.
Now: I hate samba. Configuration sucks. But the user rules. I could have added a secondary samba server (or client) on the secondary PC, then asked them to log on the proper share. But here is a very Unix way to do it:
Recently, they purchased a secondary server to off-load part of the existing services, but they would like to keep the convenient file access through Samba.
Now: I hate samba. Configuration sucks. But the user rules. I could have added a secondary samba server (or client) on the secondary PC, then asked them to log on the proper share. But here is a very Unix way to do it:
Friday, October 7, 2016
Broken bits - CNC isolation milling and V-cutters
I buy inexpensive V-cutters for milling printed circuit boards (and recently switched to 20°, sharper ones). Often, the very end of the cutter breaks on the first contact with the copper layer (it is just so delicate). Usually I have either to compensate for the missing Z depth manually, or restart the job... else it will not carve enough and will not go through the copper layer.
Wednesday, September 21, 2016
How to find a package in debian / ubuntu
Here are three different command I use to look for a linux package.
The second one is a command to install via ''sudo apt-get install apt-show-versions''. I use it often as it also lists whether the package is already installed or not.
''
[11:35][jeremie@alpha:~] apt-cache search 'sdl.*-dev'
libsdl1.2-dev - Simple DirectMedia Layer development files
erlang-esdl-dev - Erlang bindings to the SDL (development files)
libalien-sdl-dev-perl - helper to build Perl program using SDL libraries
libghc-sdl-dev - Haskell SDL binding for GHC
libghc-sdl-gfx-dev - Haskell SDL gfx binding for GHC
libghc-sdl-image-dev - Haskell SDL Image binding for GHC
libghc-sdl-mixer-dev - Haskell SDL Mixer binding for GHC
libghc-sdl-ttf-dev - Haskell SDL TTF binding for GHC
libsdl-console-dev - Console that can be added to any SDL application, development files
libsdl-gfx1.2-dev - development files for SDL_gfx
libsdl-image1.2-dev - Image loading library for Simple DirectMedia Layer 1.2, development files
libsdl-mixer1.2-dev - Mixer library for Simple DirectMedia Layer 1.2, development files
libsdl-net1.2-dev - Network library for Simple DirectMedia Layer 1.2, development files
libsdl-ocaml-dev - OCaml bindings for SDL - development files
libsdl-pango-dev - text rendering with Pango in SDL applications (development)
libsdl-sge-dev - extension of graphic functions for the SDL multimedia, development files
libsdl-sound1.2-dev - Sound library for Simple DirectMedia Layer 1.2, development files
libsdl-stretch-dev - development files for SDL_stretch library
libsdl-ttf2.0-dev - TrueType Font library for Simple DirectMedia Layer 1.2, development files
libsdl2-dev - Simple DirectMedia Layer development files
libsdl2-gfx-dev - development files for SDL2_gfx
libsdl2-image-dev - Image loading library for Simple DirectMedia Layer 2, development files
libsdl2-mixer-dev - Mixer library for Simple DirectMedia Layer 2, development files
libsdl2-net-dev - Network library for Simple DirectMedia Layer 2, development files
libsdl2-ttf-dev - TrueType Font library for Simple DirectMedia Layer 2, development files
libtaoframework-sdl-cil-dev - Tao CLI binding for SDL - development files
[11:35][jeremie@alpha:~] apt-show-versions |egrep sdl.*-dev
libsdl-image1.2-dev:amd64/xenial 1.2.12-5build2 uptodate
libsdl-image1.2-dev:i386 not installed
libsdl1.2-dev:amd64/xenial 1.2.15+dfsg1-3 uptodate
libsdl1.2-dev:i386 not installed
[11:36][jeremie@alpha:~] dpkg -l | egrep -i 'sdl.*-dev'
ii libsdl-image1.2-dev:amd64 1.2.12-5build2 amd64 Image loading library for Simple DirectMedia Layer 1.2, development files
ii libsdl1.2-dev 1.2.15+dfsg1-3 amd64 Simple DirectMedia Layer development files
- apt-cache search <regex>
- apt-show-versions | egrep <regex>
- dpkg -l | egrep -i <regex>
The second one is a command to install via ''sudo apt-get install apt-show-versions''. I use it often as it also lists whether the package is already installed or not.
The last one I forget all the time. It will show which packages are, or were, installed on your system. It is concise and it lists the architecture (32/64 bits versions).
For example, here are the three output when looking for SDL dev (which stands for "simple direct media layer", a lightweight and cross-platform framework to develop graphics and access to low-level resources).
''
[11:35][jeremie@alpha:~] apt-cache search 'sdl.*-dev'
libsdl1.2-dev - Simple DirectMedia Layer development files
erlang-esdl-dev - Erlang bindings to the SDL (development files)
libalien-sdl-dev-perl - helper to build Perl program using SDL libraries
libghc-sdl-dev - Haskell SDL binding for GHC
libghc-sdl-gfx-dev - Haskell SDL gfx binding for GHC
libghc-sdl-image-dev - Haskell SDL Image binding for GHC
libghc-sdl-mixer-dev - Haskell SDL Mixer binding for GHC
libghc-sdl-ttf-dev - Haskell SDL TTF binding for GHC
libsdl-console-dev - Console that can be added to any SDL application, development files
libsdl-gfx1.2-dev - development files for SDL_gfx
libsdl-image1.2-dev - Image loading library for Simple DirectMedia Layer 1.2, development files
libsdl-mixer1.2-dev - Mixer library for Simple DirectMedia Layer 1.2, development files
libsdl-net1.2-dev - Network library for Simple DirectMedia Layer 1.2, development files
libsdl-ocaml-dev - OCaml bindings for SDL - development files
libsdl-pango-dev - text rendering with Pango in SDL applications (development)
libsdl-sge-dev - extension of graphic functions for the SDL multimedia, development files
libsdl-sound1.2-dev - Sound library for Simple DirectMedia Layer 1.2, development files
libsdl-stretch-dev - development files for SDL_stretch library
libsdl-ttf2.0-dev - TrueType Font library for Simple DirectMedia Layer 1.2, development files
libsdl2-dev - Simple DirectMedia Layer development files
libsdl2-gfx-dev - development files for SDL2_gfx
libsdl2-image-dev - Image loading library for Simple DirectMedia Layer 2, development files
libsdl2-mixer-dev - Mixer library for Simple DirectMedia Layer 2, development files
libsdl2-net-dev - Network library for Simple DirectMedia Layer 2, development files
libsdl2-ttf-dev - TrueType Font library for Simple DirectMedia Layer 2, development files
libtaoframework-sdl-cil-dev - Tao CLI binding for SDL - development files
[11:35][jeremie@alpha:~] apt-show-versions |egrep sdl.*-dev
libsdl-image1.2-dev:amd64/xenial 1.2.12-5build2 uptodate
libsdl-image1.2-dev:i386 not installed
libsdl1.2-dev:amd64/xenial 1.2.15+dfsg1-3 uptodate
libsdl1.2-dev:i386 not installed
[11:36][jeremie@alpha:~] dpkg -l | egrep -i 'sdl.*-dev'
ii libsdl-image1.2-dev:amd64 1.2.12-5build2 amd64 Image loading library for Simple DirectMedia Layer 1.2, development files
ii libsdl1.2-dev 1.2.15+dfsg1-3 amd64 Simple DirectMedia Layer development files
''
Thge ''ii'' flags mean here "currently installed", i.e. I already have them. You can read about other installation status flags here.
Thge ''ii'' flags mean here "currently installed", i.e. I already have them. You can read about other installation status flags here.
Thursday, September 15, 2016
Lightweight video streaming from a Raspberry with h264_v4l2_rtspserver
VLC adds 330Mo to a raspbian distribution just to stream video to the network. This is huge!
Instead there is a smaller solution, with adds "only" a few dozens megabytes of buliding tools (mainly).
It just interfaces the nice standard V4L2 driver and streams it to a RTSP feed (i.e. Real Time Streaming Protocol). This is also very efficient as minimum buffering is done locally, which means faster response time (time lag is "only" 2 seconds, which is decent).
From this answer.
''
sudo modprobe -v bcm2835-v4l2
git clone https://github.com/mpromonet/h264_v4l2_rtspserver.git
cd h264_v4l2_rtspserver
sudo apt-get install libopus-dev libexpat1-dev libssl-dev libasound2-dev libudev-dev libavahi-client-dev libcurl4-openssl-dev libjs-jquery
cmake .
sudo make install
h264_v4l2_rtspserver
''
Then, the RTSP video stream can be accessed from anywhere with:
''
vlc rtsp://<raspberry>:8554/unicast
''
Note that ''h264_v4l2_rtspserver'' has a few options to optimize your bandwidth (reducing the network buffering helps also achieving a faster response time):
''
h264_v4l2_rtspserver --network-caching 300 -H <height> -W <width> -F <fps>
''
BTW some additional/alternative info for the Raspberry can be found here.
Instead there is a smaller solution, with adds "only" a few dozens megabytes of buliding tools (mainly).
It just interfaces the nice standard V4L2 driver and streams it to a RTSP feed (i.e. Real Time Streaming Protocol). This is also very efficient as minimum buffering is done locally, which means faster response time (time lag is "only" 2 seconds, which is decent).
From this answer.
''
sudo modprobe -v bcm2835-v4l2
git clone https://github.com/mpromonet/h264_v4l2_rtspserver.git
cd h264_v4l2_rtspserver
sudo apt-get install libopus-dev libexpat1-dev libssl-dev libasound2-dev libudev-dev libavahi-client-dev libcurl4-openssl-dev libjs-jquery
cmake .
sudo make install
h264_v4l2_rtspserver
''
Then, the RTSP video stream can be accessed from anywhere with:
''
vlc rtsp://<raspberry>:8554/unicast
''
Note that ''h264_v4l2_rtspserver'' has a few options to optimize your bandwidth (reducing the network buffering helps also achieving a faster response time):
''
h264_v4l2_rtspserver --network-caching 300 -H <height> -W <width> -F <fps>
''
BTW some additional/alternative info for the Raspberry can be found here.
Wednesday, August 31, 2016
Optimize a C program by visually checking the profiling data
You need ''gprof2dot.py'' (specific standalone tool) and the regular package ''dot'' (from graphviz).
''
g++ -pg -g myproc.cpp myproc
myproc myarg1 myarg2
gprof myproc | gprof2dot.py -s | dot -Tpng -o profiler.png
''
Note that the ''-g'' debugging option is required.
Note also that any code optimization flag, like ''-o3'' (aggressive speed optimization), will significantly impact the code layout, and it will be much harder to recognize the profiled sections. It is much easier to read when most optimizations are tuned off (''-o1'' or ''-o0'').
But there is a nasty trade-off... Without optimization, the overall program will certainly behave differently than in production. It will not spend the same time in the same routines. Reciprocally, with full optimization you are closer to the real program you want to probe... but it will be sometimes just impossible to recognize the source code and unrolled functions that the profiler points to.
Subscribe to:
Posts (Atom)


