Canageek is a user on cybre.space. You can follow them or interact with them if you have an account anywhere in the fediverse.
Canageek @Canageek

So, decided to write a quick calculator to work out experiment length for our flourimeter while waiting for quantum yield measurements.

Need to do this math: (((EndWavelength - StartWavelength) * DwellTime)\StepSize)\60 so pretty simple. Excel would work, but this PC doesn't have it. Can't use Google Docs, no internet.

· Web · 0 · 1

I know, dos command line. Pull out phone, google. SET /a and SET /p will work. Spend some time working on that, discover that it won't work as SET is integer math only. Ok, that is pretty useless. I guess fine for counting number of files or something.

Right, this is a modern windows computer. I look up how to do math in powershell. Much easier, but damn, powershell loves to waste characters. They did know they were written a SHELL and not a programming language, right?

Get a quick prototype done, try and run it. NOPE.

It turns out that by default you can't run powershell scripts. What? I was just running batch files from the dos command prompt. Why block powershell if you aren't got to block cmd.exe? PLUS I could type the commands directly, just not run them saved to a file.


I'm sure someone could explain why a) saving commands to a file is more dangerous then running them by typing them in line by line and b) what the point is if you don't disable cmd.exe the same way?

Here is where I really don't get: If I save "2+2" into a file called test.ps1, then powershell won't run it. If I save "powershell 2+2" into test.bat then run that from cmd.exe IT RUNS FINE.

So if I wanted to do something harmful, I could just write it in a batch file, and call on powershell for anything I needed anyway. It just makes it super hard for people that actually want to do useful stuff.

PLUS, basic scripting is one of the POINTS of computers. Everyone should be taught the principles of this stuff in school, for basic file manipulation. So many times I've been able to automate repetitive tasks in bash/cmd/awk/etc

@Canageek couldn't agree more. I taught my kids some python.
They don't actually use it... but I do get the odd hey dad, could you...?? At least they are aware.

@Canageek That is insane.
And probably why my own personal relationship with msw at home only lasted 2 months. Painfully. In the 90's...
You literally have to pay me to use it. It's such a piece of...

@gemlog Modern Windows is actually pretty good. It just tends to have stupid defaults.

I mean, I've got a compete Ubuntu install at home, within Windows, so I can call Windows executables from Bash and Vis versa. Less hacky then cygwin, but no X yet (offically anyway)

@Canageek I've added that to my win10box at work too.
Now, make a cronjob 'just work'.

@gemlog Ah, depending on the version the scheduler in Windows is pretty good as I recall. Been a while since I used it though.

@Canageek I'm just saying in ubuntu, under windows, an actual cronjob won't work thru a reboot.

I use the windows scheduler to do dyndns at one place reliably.

@Canageek Much better than cygwin. There is a hacky way to get x11 using e.g. vnc.

@Canageek I don't have it at home, because I don't use windows and I never will. You must pay me! :-)
And even then I'll complain about it!

@Canageek I have linux boxes avail + I'm the IT guy, so I can grant myself magic wishes on any machine, but I didn't know that.
I hate MS. I just do.

@Canageek No. It's live java vs python: "How can we make this line use up three times the chars?"

@Canageek bash, python, perl... I don't think I understand the problem. You could store results as csv for import to a db or spreadsheet later.

@gemlog The idea is to have a quick calculator on that computer that will spit out how long your experiment will take so that you can set an alarm on your phone and come back at the right time.

@Canageek IF this was a linux box you could control, I would write the little calculation in w/e and then email to e.g. 6041234567@telus.net which would text you.

@gemlog Oh I could write this in Bash or Awk pretty quickly.

Right now I'm thinking I can take in the input in DOS then pass it to powershell as a single command.

@Canageek Also, if the pc has a desktop, you could easily give it libre/open office (if you are allowed to install anything).

@gemlog Default windows install, so nope.

@gemlog I don't think I am, and we don't want too much stuff installed on this computer, since it should only be for running this one instrument.

@DialMforMara Deflates the point of having a tool on the computer anyone in my lab can use.

@DialMforMara @gemlog Yeah, I mean, I can just use the windows calculator to do this, but I was hoping to make it faster then stopping to pull out my phone, open calc, etc. Was hoping for click icon, enter numbers, see answer. Which, if SET /a would do decimal math, OR powershell worked would be easy to do. I suppose I could install LibreOffice or Cygwin, or Ubuntu for Windows, but kind of overkill.

@Canageek @DialMforMara libreoffice is USually a quick install if you have the perms. No biggy.
Did find a problem installing on win8 the other day though related to VB.
Had to go back to an earlier version.