General tools used here

Well, it appears there's no really good way to do this here. This will contain various bits of code used to support the fusor, which presently includes everything from embedded 8 bit uP code to stuff to run under Linux in some HLL (often perl) to interface-specific stuff for commercial hardware, sysadmin tips and setups, and running on whatever machines I have in the tree here. So any one piece might fit some other category too, but...there's no pigeon-holing even computer science without losing the app-specific stuff and inter-relations of it all in a specific usage.
Forum rules
Code sharing for fusor data aq and control software

General tools used here

Postby fusordoug » Sun Mar 05, 2017 12:35 pm

I'm a Linux guy since way back when I stopped getting paid good money to fix windows issues and write code for windows customers. Worse yet, I'm a perl guy when it comes to high level languages and C or C++ would just take too many keystrokes.
I do try to write perl as though it were C, and make it readable, is all I can use as a defense...well, and there's CPAN. I use C or the relaxed version of C++ that arduinos, teensys, ESP xxxx, and so forth use, as those are often single-purpose machines with one goal in life - do something well, and on time (kind of like the linux philosophy without linux, I know).
I use NGINX exclusively, whether on a big box or a raspberry pi, when I need a web server inside the LAN (which is all of them so far). If you have to learn one of the two big ones, it's the easier one, and it's faster.
I use MySQL (yes, I hate Oracle too...) again, it's fast, it's free, and it's good enough. I note there are more or less plug-in replacements for most machines, but maybe not so much for raspberry pies, which is one place I use it.
I use VirtualBox when necessary, if for no other reason than to have a windows around so as to reverse engineer protocols for devices with crappy windows-only code. I still don't like Oracle.

I cobble together hacks from other people's code in their languages of choice, even if they make me throw up in my mouth a little. If Adafruit has a nice python library for something weird on a pi, after all, I can just use Inline::Python in perl and use it.
Similar issues with raspi cam web software - they use C, javascript, php and gawd knows what else, but actually command that mess via linux FIFO files (which are actually named things like FIFO!), so if I need remote control and don't have time to re-write the wheel, maybe I just share that FIFO via Samba and write into it from elsewhere. And there's always shell, which I don't like but speak/read enough of to get by. I might use Samba to share crucial files and directories to do things like that, and gack - hardcode the names to identify the guilty. So you can take these examples and use them, but likely you'd have to do some sysadmin and renaming in the code itself and elsewhere to make it work for you. This is more "one way it can work" than "this is how everyone should do it for mass consumption". It's the difference between code I call "research grade" which you run to get the answer, maybe only once or on one system, and "production grade" which is supposed to work for everyone no matter how brain dead they are - I usually don't have time to hew to that quality level, and wouldn't you know it, if you do, the very next version of whatever opsys or IDE invalidates your automatic install code, changes your dependencies and so on - and I don't have time to support the planet on this stuff - I just need it for me. I will even avoid going to the latest opsys if it might mean breaking a bunch of this kind of interacting code and sysadmin work.

People new to linux, which at one time was me too - are often messed up by the fact that often you can spend hours googling things, find endless answers that aren't right for the current version or your problem, and then when you find the answer it's a simple one or few word edit in some config file (this is somewhat the case for windows as well, only using the MSDN dox). To help with my own sanity, I plan to backup some of those (usually but not always found in /etc) here too, as an amazing fraction of what has made all the fusor stuff play nice together is actually just configuration setups - I'm at heart a programmer, not a sysadmin, but one does what needs to be done to get 'er done before one's expiration date arrives.

IN general I'm using this board a lot to just backup things that worked for me - it's a nice offsite backup, and the format lends itself well to the "what was the guy thinking" kind of posting that is often even more helpful than the inline comments, which I do attempt to put in my code when they won't be too distracting.

Rule one when looking at my code: search for @@@. I put that somewhere in any comment on code that's either dodgy, surprising, bad practice but I cheated...that kind of thing. If you have a problem...it's likely there.

I deliberately do some bad practices, or at least they would be if "great mind didn't run in the same track" - stuff that would be poison on a team project, like "overuse of global variables". Which if one doesn't know what's valid when, one might write code that clobbers them at bad times and create "funny action at a distance". But hey, it's just me, it saves time (both mine and the computer's) and as the old saying goes "show me your data and I won't need to see your flowcharts" so keeping it all up front isn't always a bad thing, particularly if the names are good (I try, but...).
Why guess when you can know? Measure!
User avatar
fusordoug
Site Admin
 
Posts: 46
Joined: Wed Jul 14, 2010 1:59 pm

Re: General tools used here

Postby Doug Coulter » Sun Mar 05, 2017 1:09 pm

Forgot to mention, on linux, make a directory under your home and call it bin (lowercase). Linux will put it on the executable path at boot thereafter and that will save you some typing and keep your custom stuff separate from systems stuff.
The linux stuff on this forum assumes you've done that, and that's where you put these things.

Install cpanminus (which is then called cpanm on the command line and run as root/sudo). When it works it's great. When things don't work, try finding the missing dependency inside synaptic, often with lib prepended to the module name and maybe -perl postfixed to it (leave those out and search will usually find it anyway).

For arudino IDE stuff I use a dir I call /home/doug/ardsketch, but that name matters not. It's just that I wrote some nifty rsync-using shell scripts that let me upload anything new I write to my NAS (a raspberry pi with a 2 tb disk drive on it) and then update whatever computer I happen to be working at the moment with the latest-greatest.

Computers are like kids that think I'm their creator (often the actual case, I've been at this since before ICs existed) and follow me around. I split up my work on them some - a few are specialized for this or that, sometimes it's just a matter of what room or chair I feel like sitting in. A NAS is a great thing to have in that case. Most people would say I have too many, and they'd probably be right, but can you really have too many toys? I suppose, space is my final frontier for them - no place to put more!

Maybe I should put the NAS stuff up here too, but it'd take a whole pi image to really do that - there's a ton of sysadmin tricks after the basic install. For hi-rel pies I only use the SD card for the MBR and the /boot partition, and something else (in that case a 2 tb laptop drive and sata<>USB cable) for everything else. That way the constant pounding done by various log functions doesn't have to wear the SD card out, and I don't have to find out the source of and stop all those silly writes - who knows, those logs might be handy someday anyway. In my own case here, I even put PHPBB on my NAS to keep notes to myself with (same as this board). Silly use of bytes perhaps, but since they are so cheap and easy...

Syntax highlighting - don't leave home without it! Gedit on linux isn't bad for a lot of languages, but sometimes gets confused if you get too fancy (which might be a feature). I use Padre on platforms that still support it. Yes, it has a couple of bugs, but the code navigation is a life-saver sometimes, and a time saver the rest of the time. I have no idea how hard it would be to get on newer linux versions, haven't tried that yet. Do use something. When your entire screen turns pink or whatever, you'll know just where you forgot to close those quotes and so forth, before even trying to run or build the code.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: General tools used here

Postby Bob Reite » Wed Mar 08, 2017 10:05 pm

I like that trick of putting stuff in /home/username/bin/ Easier I think than using /usr/local/bin
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Re: General tools used here

Postby Doug Coulter » Sun Mar 12, 2017 10:55 am

Me too. Makes privileges easier to sort out, and keeps my "special to me or this specialized box" stuff out of the system directories, which makes backing up and upgrading easier (if most of your custom stuff lives in /home/...vs all over the box). Still doesn't solve all the customization stuff we tend to do in /etc, but it's one less thing to get wrong, and usually a lot easier to search through if you kinda forgot exactly how you named something...

At least nearly all the stuff you do in /etc/* for you-name-it system services from web servers to file shares to databases is documented and is about the same everywhere - doesn't even change much across distros or revs. Just /etc/rc.local for we old farts who want our special stuff to run at startup and are too busy to work out how to do it in systemd's flavor of the month...

I guess even linux distros assume no one's going to write their own code for anything...they make provision in the startup files to put it on the path if it exists, but then don't put the dir in there by default. Duh?
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: General tools used here

Postby Bob Reite » Thu Mar 16, 2017 10:18 pm

Ah yes. rc.local Fail2Ban recommends doing your customization in /etc/fail2ban/jail.local, so that when you upgrade, your settings will be preserved.

guess even linux distros assume no one's going to write their own code for anything...they make provision in the startup files to put it on the path if it exists, but then don't put the dir in there by default. Duh?


I guess they figure if you are into writing your own code you'll know how (or how you want to) set up the paths for where your program will live and do it's thing.
The more reactive the materials, the more spectacular the failures.
The testing isn't over until the prototype is destroyed.
User avatar
Bob Reite
 
Posts: 142
Joined: Wed Nov 11, 2015 1:02 pm
Location: Wilkes Barre / Scranton PA

Re: General tools used here

Postby Donovan Ready » Fri Mar 17, 2017 8:35 pm

And what directories to include when you make that tarball you're supposed to do every night. :mrgreen:
Donovan Ready
 
Posts: 239
Joined: Thu Apr 17, 2014 1:22 pm
Location: Austin, Texas

Re: General tools used here

Postby Doug Coulter » Thu Mar 23, 2017 1:37 pm

I'm gonna get that religion - I just finished spending two whole days rebuilding a rasberry pi based camera for integration into the fusor data acquisition, as the old one started dropping frames due (I think) to USB stick corruption...Still in testing, that one, and it's important. I'd not been backing this kind of thing up, since 99.999 (or howevermany) 9's of it is just getting, installing, and configuring stuff...with maybe 10-20 lines of actual code. But still...getting all this stuff and making it work together is not a super trivial task, and I guess I lack the patience to build a script to do it all again (heck, I'd even ned sed etc as some things come with odd wrong characters in config files, as I mentioned in the pi cheat sheet thread).

This time I backed that all up to my shop share (another raspi that has a 2tB disk on it). Took a long time, but if it saves me just once (think of the chillin)... ;)
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: General tools used here

Postby Doug Coulter » Thu Apr 06, 2017 3:36 pm

I succumbed to software lust and actually bought an editor. I think it was fair dinkum. Sublime text. While it doesn't handle my language of choice (perl) perfectly - and it seems nothing, even Padre does - it's darn good, and handles a lot of languages with really cool features (even column-select and editing), good customization, speed and grace. While it doesn't have the sidebar that lists all the symbols in a program, they are there in a dropdown for navigating.
Here's a picture of it in action:
SublimeText.png
Nice tool...
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Fusor support

Who is online

Users browsing this forum: No registered users and 1 guest