Archive for the ‘Scripting’ Category
Posted by jpluimers on 2014/10/30
PowerShell does some powerful conversions.
Always be aware of that, especially when using booleans. For instance: strings are always TRUE, and $ inside strings are not always evaluated, and often people you define their own string to boolean conversions.
It is better to use the automatic variables $True and $False when you really want to make something is TRUE or FALSE.
Read Boolean Values and Operators – Windows PowerShell Blog – Site Home – MSDN Blogs why.
Oh and don’t forget to turn Strict-Mode on to warn for uninitialized variables and other stuff (as of PowerShell version 2; use Set-PsDebug -strict if you are still in PowerShell version 1)
–jeroen
Posted in Development, PowerShell, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2014/10/08
I never realized you could overwrite the CD pseudo environment variable. If you do, the automatic value of the pseudo variable will not be udpated any more:
You have at some point set the CD variable explicitly. If you do this it will no longer automatically reflect the current working directory. To undo this, set it to empty:
set CD=
Thanks Jonathan and … for explaining this in both your answers.
Thanks to another answer by Endoro I now also know of the %=C:% pseudo variable (you have one per drive letter) that indicate the current directory per drive letter.
–jeroen
via: batch file – When is the CD environment variable updated? – Stack Overflow.
Posted in Batch-Files, Development, Power User, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | 2 Comments »
Posted by jpluimers on 2014/10/06
I just found this [Wayback] great answer (which by now regrettably is deleted; the previous Wayback link still has it) by [Wayback] Јοеу a.k.a. Johannes Rössel on [Wayback] What encoding/code page is cmd.exe using.
The whole answer is worth reading, so I won’t quote only some bits.
Edit 20210609: the answer now has been replaced by an even more detailed answer [Wayback] by [Wayback] andrewdotn. Also recommended reading. The summary of the new answer is this:
The moral of the story?
type can print UTF-16LE files with a BOM regardless of your current codepage
- Win32 programs can be programmed to output Unicode to the console, using
WriteConsoleW.
- Other programs which set the codepage and adjust their output encoding accordingly can print Unicode on the console regardless of what the codepage was when the program started
- For everything else you will have to mess around with
chcp, and will probably still get weird output.
–jeroen
via: windows – What encoding/code page is cmd.exe using – Stack Overflow.
Posted in Batch-Files, Development, Encoding, Power User, Scripting, Software Development, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Leave a Comment »
Posted by jpluimers on 2014/09/25
Unpatched bash allows for remote code execution.
Patch as soon as you can and be aware that the current patches might not be complete.
Many vendors (including Debian, Red Hat, SuSE, Ubuntu) already have patches available: CERT/NIST reveal level 10 bash alert today, 24 September 2014.
This is a long article which explains the why/how/… and has an easy check to see if you are vulnerable: What is the CVE-2014-6271 bash vulnerability and, how do I fix it.
It looks like the current patches aren’t complete yet, but do plug big parts of the hole.
Watch bash CVEs in Ubuntu and CVE-2014-7169 in Ubuntu (and maybe for other nx varieties as well).
Update:
Quote from the article:
Read the rest of this entry »
Posted in *nix, *nix-tools, bash, Development, Power User, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2014/09/25
If you are going to do test driven development and unit testing, you should watch these videos and slide decks, most of them by Miško Hevery:
- Not a video, but a good starter: Guide: Writing Testable Code (or read the PDF version).
- 0:32:07 ▶ “The Clean Code Talks — Unit Testing” – YouTube.
- 0:37:56 ▶ The Clean Code Talks – Don’t Look For Things! – YouTube. Read the rest of this entry »
Posted in .NET, Agile, C#, Delphi, Development, Java, Java Platform, JavaScript/ECMAScript, Pascal, Scripting, Software Development, Unit Testing, VB.NET | 2 Comments »
Posted by jpluimers on 2014/09/17
Great to see the French company revolunet list a lot of non-French books on JavaScript and Python:
So where their government tries to make radio stations, written press, etc to favour French over other languages, French companies look beyond their borders.
Great!
–jeroen
via: revolunet: Rich Web Applications, HTML5, Sencha Touch, ExtJS, Phonegap.
Posted in Development, JavaScript/ECMAScript, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2014/08/21
Just in case I need this again:
None of the mutt ones worked for me. It was thinking the email address was part of the attachemnt. Had to do:
echo “This is the message body” | mutt -a “/path/to/file.to.attach” -s “subject of message” — recipient@domain.com
Thanks Alexander Bird for noticing the double-dash, rynop for the modified answer and Chris N for the original answer.
From mutt(1): Mutt Mail User Agent – Linux man page: Read the rest of this entry »
Posted in *nix, bash, Development, Linux, Power User, Scripting, Software Development, SuSE Linux | Leave a Comment »
Posted by jpluimers on 2014/08/20
In the the irregular series of ASUS RT-N66U and TomatoUSB posts:
Execute this script from the Tomato USB interface, or a ssh/telnet shell:
cat /dev/mtd0ro | grep bl_version
nvram get os_version
nvram get clkfreq
wl -i eth1 phy_tempsense | awk '{print $1/2+20;}'
wl -i eth2 phy_tempsense | awk '{print $1/2+20;}'
- Line 1 gets the CFE bootloader version
(1.0.2 and lower boot with 32K of NVRAM, 1.0.3 and up with 64K of RAM; some Firmwares work around the 32k limitation)
- Line 2 gets the Firmware model and version
- Line 3 gets the CPU speed
- Line 4 and 5 get the temperature for eth1 (2.4 Ghz) and eth2 (5 Ghz) in Celsius
It is based on the RMerlinDev (firmware developer) information on temperatures: These are for each radio. Take the returned value, divide by 2, then add 20. Results are in Celcius.
Next to that knowledge, it uses a few tricks on awk calculation, and first parameter in awk (the second parameter would be the hex value of the temperature code in parenthesis) which is easier than shell calculations.
Based on those, I found a few very useful scripts:
–jeroen
Posted in ASUS RT-N66U, Awk, bash, Development, Internet, Network-and-equipment, Power User, Scripting, Software Development, TomatoUSB | Leave a Comment »
Posted by jpluimers on 2014/08/05
I’ve done a bit of WinWord automation and came across different locations for the API:
New Style:
Old Style:
Fun fact: there is no Old Style Word 2007 documentation any more. You might expect it at http://msdn.microsoft.com/en-us/library/ms263641(v=office.12) but it is not there.
Not so fun fact (and the reason I was looking for the Documents documentation), is because of this big bug ONLY in Office 2010 (it does not occur in Office 2000 .. 2007, and is fixed in 2013): The WordMeister » Bug Word 2010: Documents collection is not correctly maintained.
The only workaround is to run an Office Add-in, or VBA Macro. Both not feasible for external clients.
–jeroen
Posted in Delphi, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Development, Office, Office 2007, Office 2010, Office 2013, Office Automation, Office VBA, Power User, Scripting, Software Development, VBScript | Leave a Comment »