2019-12-31
The secret index of all Stack Overflow blog posts
Note that, for the current year, the page numbers change as new blog posts are added to the Stack Overflow blog. So this is an appropriate day to publish it!
2019-12-08
Getting the ARM toolchain to work on Ubuntu 19.04 and later
See my blog post "Getting the ARM toolchain to work on Ubuntu 19.04 and later" (no, not this one).
This is an update to "Getting started with 1Bitsy and Black Magic Probe" (which only works up until Ubuntu 18.04 (Bionic Beaver)).
2019-10-04
PowerShell aliases and missing Microsoft documentation
Unfortunately, in most cases, Microsoft's documentation for a PowerShell cmdlet is lacking information about the aliases.
For instance, the documentation for Get-ChildItem fails to include information about the aliases ls, dir, and gci.
Resolution
Running cmdlet Get-Alias in a PowerShell session will list all aliases (for that version of PowerShell).
The interesting fields in the output from Get-Alias are:
"Name" The alias. E.g. "ls"
"Definition" The cmdlet. E.g. "Get-Content"
Get-Alias by itself will (roughly) output in alphabetic order of the aliases. Probably more interesting is grouping by cmdlets and then the aliases for that cmdlet in alphabetic order (sort with primary key on "Definition" and secondary key on "Name"):
Get-Alias | select Name, Definition, DisplayName | Sort-Object Definition, Name
Note that the alias "sort" for "Sort-Object" can not be used with later versions of PowerShell on Linux (yes, with PowerShell 6 released in 2016 it runs on Linux).
If the output is needed in some particular format, e.g., rows in an HTML table:
Get-Alias | select Name, Definition, DisplayName | sort Definition, Name | foreach { "<tr> <td>{0,1}</td> <td>{1,1}</td> </tr>" -f $_.Name, $_.Definition }
Interesting aliases
Some short aliases are:- % is an alias for ForEach-Object. ForEach-Object is also commonly known by another alias, foreach.
- ? is an alias for Where-Object. Where-Object is also commonly known by another alias, where
- h is an alias for Get-History. Another alias is ghy.
- ps (like on Unix) is an alias for Get-Process.
List of aliases
| Alias | Cmdlet |
|---|---|
| asnp | Add-PSSnapIn |
| clc | Clear-Content |
| clhy | Clear-History |
| clear | Clear-Host |
| cls | Clear-Host |
| cli | Clear-Item |
| clp | Clear-ItemProperty |
| clv | Clear-Variable |
| compare | Compare-Object |
| diff | Compare-Object |
| cnsn | Connect-PSSession |
| CFS | ConvertFrom-String |
| cvpa | Convert-Path |
| copy | Copy-Item |
| cp | Copy-Item |
| cpi | Copy-Item |
| cpp | Copy-ItemProperty |
| dbp | Disable-PSBreakpoint |
| dnsn | Disconnect-PSSession |
| ebp | Enable-PSBreakpoint |
| etsn | Enter-PSSession |
| exsn | Exit-PSSession |
| epal | Export-Alias |
| epcsv | Export-Csv |
| epsn | Export-PSSession |
| % | ForEach-Object |
| foreach | ForEach-Object |
| fc | Format-Custom |
| fhx | Format-Hex |
| fl | Format-List |
| ft | Format-Table |
| fw | Format-Wide |
| gal | Get-Alias |
| dir | Get-ChildItem |
| gci | Get-ChildItem |
| ls | Get-ChildItem |
| gcb | Get-Clipboard |
| gcm | Get-Command |
| gin | Get-ComputerInfo |
| cat | Get-Content |
| gc | Get-Content |
| type | Get-Content |
| ghy | Get-History |
| h | Get-History |
| history | Get-History |
| gi | Get-Item |
| gp | Get-ItemProperty |
| gpv | Get-ItemPropertyValue |
| gjb | Get-Job |
| gl | Get-Location |
| pwd | Get-Location |
| gm | Get-Member |
| gmo | Get-Module |
| gps | Get-Process |
| ps | Get-Process |
| gbp | Get-PSBreakpoint |
| gcs | Get-PSCallStack |
| gdr | Get-PSDrive |
| gsn | Get-PSSession |
| gsnp | Get-PSSnapIn |
| gsv | Get-Service |
| gtz | Get-TimeZone |
| gu | Get-Unique |
| gv | Get-Variable |
| gwmi | Get-WmiObject |
| group | Group-Object |
| man | help |
| ipal | Import-Alias |
| ipcsv | Import-Csv |
| ipmo | Import-Module |
| ipsn | Import-PSSession |
| icm | Invoke-Command |
| iex | Invoke-Expression |
| ihy | Invoke-History |
| r | Invoke-History |
| ii | Invoke-Item |
| irm | Invoke-RestMethod |
| curl | Invoke-WebRequest |
| iwr | Invoke-WebRequest |
| wget | Invoke-WebRequest |
| iwmi | Invoke-WMIMethod |
| measure | Measure-Object |
| md | mkdir |
| mi | Move-Item |
| move | Move-Item |
| mv | Move-Item |
| mp | Move-ItemProperty |
| nal | New-Alias |
| ni | New-Item |
| nmo | New-Module |
| mount | New-PSDrive |
| ndr | New-PSDrive |
| nsn | New-PSSession |
| npssc | New-PSSessionConfigurationFile |
| nv | New-Variable |
| ogv | Out-GridView |
| oh | Out-Host |
| lp | Out-Printer |
| popd | Pop-Location |
| ise | powershell_ise.exe |
| pushd | Push-Location |
| rcjb | Receive-Job |
| rcsn | Receive-PSSession |
| del | Remove-Item |
| erase | Remove-Item |
| rd | Remove-Item |
| ri | Remove-Item |
| rm | Remove-Item |
| rmdir | Remove-Item |
| rp | Remove-ItemProperty |
| rjb | Remove-Job |
| rmo | Remove-Module |
| rbp | Remove-PSBreakpoint |
| rdr | Remove-PSDrive |
| rsn | Remove-PSSession |
| rsnp | Remove-PSSnapin |
| rv | Remove-Variable |
| rwmi | Remove-WMIObject |
| ren | Rename-Item |
| rni | Rename-Item |
| rnp | Rename-ItemProperty |
| rvpa | Resolve-Path |
| rujb | Resume-Job |
| select | Select-Object |
| sls | Select-String |
| sal | Set-Alias |
| scb | Set-Clipboard |
| sc | Set-Content |
| si | Set-Item |
| sp | Set-ItemProperty |
| cd | Set-Location |
| chdir | Set-Location |
| sl | Set-Location |
| sbp | Set-PSBreakpoint |
| stz | Set-TimeZone |
| set | Set-Variable |
| sv | Set-Variable |
| swmi | Set-WMIInstance |
| shcm | Show-Command |
| sort | Sort-Object |
| sajb | Start-Job |
| saps | Start-Process |
| start | Start-Process |
| sasv | Start-Service |
| sleep | Start-Sleep |
| spjb | Stop-Job |
| kill | Stop-Process |
| spps | Stop-Process |
| spsv | Stop-Service |
| sujb | Suspend-Job |
| tee | Tee-Object |
| trcm | Trace-Command |
| wjb | Wait-Job |
| ? | Where-Object |
| where | Where-Object |
| echo | Write-Output |
| write | Write-Output |
Platform
This was tested on Windows 10 and PowerShell 5.1:
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 18362 145
2018-09-10
Current podcasts (2018)
Here is my current list of podcasts. It is shorter than the previous, mostly due to a move to a new computer.
The links are RSS URLs.
- Millionærklubben (Financial. In Danish)
- Geocast Geography, but also astronomical content, like the current series about planetary science.
- Security Now
- EEVBlog Electronics. Video blog.
- Embedded.fm Embedded software development.
- The Amp Hour Partly the podcast companion to EEVBlog (if and when Dave Jones shows up)
- Gravity Assist Space missions, mostly planetary.
- .NET Rocks Software development with .NET, but also other kinds, like C++.
- Developer on Fire Mostly about soft skills related to software development
- Complete Developer Podcast Covers all aspects of software development
- This Week in Google Nominally about Google, but in reality all things going on in the tech industry, with an emphasis on the Internet
- Hanselminutes About software development, with a high diversity of the interviewees.
- Astrocast Astronomy, by an actual professional astronomer.
2018-04-07
Using ChatZilla in the age of Firefox Quantum
But Firefox Quantum (Firefox from v. 56 and later, end of 2017) has introduced a lot of confusion as it breaks a lot of extensions, including ChatZilla, so it appears it can not be used any more. But it can!
Note that SeaMonkey promises to have ChatZilla built in (and presumably working), but that is because their documentation has not been updated. It is actually not included in the later versions. It suffers from the same problem as Firefox as it based on the Firefox code base. You have to get some year-old version to get it working.
Instead it is much easier to install ChatZilla as an independent application (that doesn't share any setting with Firefox or SeaMonkey) - ChatZilla can also run as a normal application under XULrunner. Even though XULrunner has been deprecated for a long time there is a version of ChatZilla available for it (there are of course security implications, but as long as it used in the limited fashion here it should not be a problem).
HowTo
- Download the XULrunner version of ChatZilla
From http://chatzilla.rdmsoft.com/xulrunner/, e.g. http://chatzilla.rdmsoft.com/xulrunner/download/chatzilla-0.9.92.en-US.win32.installer.msi
It is about 36 MB.
- Install ChatZilla by opening the downloaded MSI file
- Add the "sigrok" IRC channel:
Menu "ChatZilla" → "Preferences" → Global settings:
Nick name:<Your preferred IRC nickname - one word, no spaces>
Menu "IRC" → "Join channel"
Network: freenode
Channel: sigrok
- Set up logging
In this example, for base folder "C:\UserProf\IRC logs". The actual log files are burried two levels deeper, in this example in folder "C:\UserProf\IRC logs\freenode\channels", with file names like "#sigrok.2018-04-07.log".
Menu "ChatZilla" → "Preferences" → "Global Settings" → "Logging":
"Log folder": file:///C:/UserProf/IRC%20logs/
Note: It is NOT necessary check "Log this view" (for this global setting) - this is done for the specific channel, in this case "sigrok".
Menu "ChatZilla" → "Preferences" → "freenode/#sigrok" → "Logging": Check the checkbox. - Show timestamps:
Menu "View" → "Show Timestamps" - Rejoin the channels when the program is restarted or the computer is restarted:
Right click "#sigrok" at the lower left and check "Open This Channel at Startup". - Put a shortcut of ChatZilla in the startup folder
<Windows key> + R, "shell:startup" (this will open a window with the startup folder) <Windows key> + "chat" → right click on "ChatZilla" → "Open file position" → right drag "ChatZilla" to the startup folder (the window that was opened with "shell:startup"), and select "Create shortcut here".
2018-03-31
Level shifter, 18 V to 5 V
The requirement was that it should work up to 3 MHz.
1. BJT inverter
This is a simple way, 2 resistors and a transistor (BC547B), but it is also shockingly slow. Both in simulation in LTSpice and in a realised circuit it could not even handle a 50% dutycycle 1 MHz squareware.
2. Resistive divider
This will not work due to the relative low input impedance of the TTL. The output swing is reduced to 1.3 V (1.1 V to 2.4 V).
3. Diode
Here we use let the internal pull-up in the TTL part for the high signal and place a diode in reverse so the output stage of the CMOS get a low-impedance path to pull the signal low. The input voltage will be close to the limit, about 0.7 V due to the diode voltage drop.
2017-06-14
Getting started with 1Bitsy and Black Magic Probe
The Kickstarter project was great, but how do you actually get started using the two things, 1Bitsy and Black Magic Probe, once they are in your possession???
There is information about the devices, but not actually how to get started - like a step-by-step introduction with the blinking LED (single stepping over the code lines for ON and OFF would actually turn the built-in LED on and off). Or at least it is difficult to find - why isn't it featured very prominently? Where is the blog post that gets you started?
So far the best I have found is the YouTube video 1Bitsy & Black Magic Probe Linux Quickstart Tutorial (and now with a transcript for the many required command-line commands - by yours truly).
I am also posting the transcript here due to the ephemeral nature of YouTube comments:
Transcript for commands and links
Notes:
Unlike the video, the three hardware connect events (indicated in the below) should be separate to get the same output on the command line as in the video.
I have also inserted the missing 'cd' to the 'fancy blink' directory (with the .elf file).
For a live USB Ubuntu 17.10 installation it was also necessary to install 'make' (added to the transcript).
For another install variation of Ubuntu 17.10 (regular install on an external USB SSD drive), also 'python-minimal' (for Python 2 - Python 3 was already installed).
Even newer versions of Ubuntu from 2019 (Ubuntu 19.04 and later), rendered the apt-get method (the first three steps here) for installing the cross GCC compiler and GDB useless. Installation fails with an error, and the rest will fail as a result. Solution: A follow-up blog post provides a solution that works, "Getting the ARM toolchain to work on Ubuntu 19.04 and later".
01 min 10 secs sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
01 min 30 secs sudo apt-get update
01 min 38 secs sudo apt-get install gcc-arm-embedded
01 min 51 secs sudo apt-get install git
XX min XX secs sudo apt-get install make
XX min XX secs sudo apt-get install python-minimal
02 min 02 secs git clone https://github.com/1bitsy/1bitsy-examples.git
02 min 07 secs cd 1bitsy-examples
02 min 12 secs git submodule init
02 min 15 secs git submodule update
02 min 21 secs make
02 min 28 secs id
02 min 32 secs sudo adduser $USER dialout
02 min 41 secs id
02 min 48 secs <The output should include "(dialout)" in the "groups=" part. In that case, log out. If it is not in the output, a restart of the computer is required (if a restart is not done the result is "Permission denied" in the "target extended-remote /dev/ttyACM0" line below).>
04 min 54 secs <Plug in Black Magic Probe to microUSB>
05 min 32 secs dmesg | tail
05 min 34 secs <Output includes: "ttyACM0" and "ttyACM1". "ttyACM0" is the COM port that GDB uses to communicate with the Black Magic Probe and "ttyACM1" is the auxiliary COM port that can be used to connect to the target board's serial port (so it is not necessary to use a separate USB-to-serial adapter).>
05 min 42 secs <Plug in 1bitsy to microUSB>
05 min 43 secs dmesg | tail
05 min 44 secs <Output includes: "ttyACM2" - but ONLY if there is already firmware on it that makes it appear as a serial device. This is NOT the case for the Kickstarter one...>
05 min 45 secs <Connect 1bitsy and Black Magic Probe using the JTAG cable. Note: the ribbon cable is to come from the SAME DIRECTION as the USB cable. That is, the ribbon cable does NOT cover the main chip/IC.>
05 min 48 secs cd ~/1bitsy-examples/examples/1bitsy/fancyblink
05 min 49 secs arm-none-eabi-gdb fancyblink.elf
05 min 54 secs target extended-remote /dev/ttyACM0
06 min 04 secs monitor version
06 min 11 secs monitor help
06 min 17 secs monitor jtag_scan
06 min 23 secs attach 1
06 min 27 secs load
06 min 30 secs run
06 min 32 secs y
06 min 37 secs <Ctrl + C>
06 min 38 secs list
06 min 43 secs tui enable
06 min 47 secs cont
06 min 51 secs <Ctrl + C>
06 min 52 secs step
06 min 53 secs start
06 min 56 secs y
07 min 00 secs next
07 min 04 secs step
07 min 07 secs next
07 min 07 secs next
07 min 17 secs next
07 min 22 secs cont
07 min 24 secs <Ctrl + C>
07 min 25 secs quit
07 min 26 secs y
07 min 26 secs y
DFU part:
07 min 44 secs <Press the user button and insert microUSB cable>
07 min 47 secs dmesg | tail
07 min 50 secs lsusb
07 min 54 secs <Output includes: "STMicroelectronics STM Device in DFU Mode">
07 min 57 secs sudo apt-get install dfu-util
08 min 13 secs make fancyblink.bin
08 min 18 secs ls
08 min 23 secs sudo dfu-util -d 0483:df11 -c 1 -a 0 -s 0x08000000:leave -D fancyblink.bin
09 min 07 secs <1bitsy is now programmed!>
09 min 10 secs <Links: <http://1bitsquared.com> (1BitSquared USA), <http://1bitsquared.de> (1BitSquared Germany), <http://1bitsy.org> (1Bitsy), and <http://github.com/blacksphere/blackmagic> (Black Magic Probe) >
Perhaps this blog post will do (covers Linux, Mac OS X, and Windows):
1Bitsy Quickstart Guide, Quickstart on the command line
A partial one (but with more in-depth explanations) is:
Getting Started (on GitHub, blacksphere/blackmagic)
Some GBD commands
next (n) Step over
step (s) Step into
???? Step out
break 37 Set breakpoint at line 37
???? Set up watch for variable X
Other resources:
Blackmagic probe Windows driver install tutorial (YouTube video. It only contains instructions for installing the three different USB drivers, one for DFU (for Black Magic Probe itself) and the two that makes for the two virtual COM ports. And only for Black Magic Probe, not 1Bitsy.)
2017-04-16
Emacs basics
Exit Emacs
Ctrl + X Ctrl + C.
M-x notation
"M" is effectively "Alt" (on most systems).
Thus M-x means Alt + X.
C-x notation
"C" is effectively "Ctrl" (on most systems).
Thus C-x means Ctrl + X.
Creating/locating the settings file
Alt + X customize. Press "Apply and Save" (Emacs 24 for Windows). This will create the file ".emacs" in C:\Documents and Settings\username\Application Data or C:\Users\username\AppData\Roaming depending on the Windows version.
Locate it by: Ctrl + X D ~/ Return
Add modes/Elisp code
<This section is under construction...>
Example: Add the Intel-hex-mode Elisp code
Download it and copy file intel-hex-mode.el to the same folder as file .emacs.
Add this to .emacs:
(require 'intel-hex-mode)
Files
To open a file: Ctrl + X Ctrl + F Enter <Select file> Enter
To save: Ctrl + X Ctrl + W Enter y
Ctrl + X O to switch in split windows (e.g. after Ctrl + X B).
Ctrl + X Ctrl + B to get a list of windows (buffers).
Ctrl + X B to switch between windows.
To be continued...
2016-12-31
Installing a Subversion server on a (new) Raspberry Pi, Apache 2.4
Installing a Subversion (SVN) server on a Raspberry Pi used to be (relatively) straightforward (see Appendix A).
This worked without problems on an older Raspberry Pi earlier this year when I had the need to set up a test server for some heavy SVN operations (before unleashing them on the real SVN server at work).
However, repeating the same installation steps on a newer Raspberry Pi (model 3, with Wi-Fi) failed to get a working SVN server. Installing an SVN server in another place was a reasonable way to reset the server state such that adding of new files could be tested more than once (and not erasing the rich history on the old server) and also a way of testing the installation procedures should they be needed again in some other place and time.
Having the older server still working I had the luxury of being able to compare configuration files for Apache and SVN. However, nothing appeared to be incorrect.
One difference was that, by the same installation procedure, eight months apart, Apache 2.2 had been installed on the old server and Apache 2.4 on the new server. It later became clear that the way of configuration has changed significantly between Apache 2.2 and Apache 2.4.
Long story short, a symbolic link for enabling the SVN thing in Apache was not created (perhaps a bug in the installation scripts or change to defaults) in the new installation. Detection became:
ls -ls /etc/apache2/mods-enabled | grep svn
This was empty (symbolic link not present) on the new server, but on the old working server the output was:
dav_svn.conf -> ../mods-available/dav_svn.conf
dav_svn.load -> ../mods-available/dav_svn.load
There is (apparently) a standard mechanism for making these symbolic links by use of the script a2enmod and the fix/solution was:
sudo a2enmod dav_svn
sudo service apache2 restart
Retrospectively, I found a Stack Overflow post, Configuring SVN server on Apache on Ubuntu 12.04, that had the exact solution. I had failed to locate it (one of the first steps was of course to search on Stack Exchange sites, primarily Stack Overflow, but also Super User and Server Fault).
Appendix A Installing an SVN server on a Raspberry Pi from scratch (with Apache for HTTP access)
These are command lines, done remotely over SSH using PuTTY on Windows.
sudo apt-get update
sudo apt-get install subversion
sudo apt-get install libapache2-svn
sudo apt-get install apache2
sudo service apache2 restart
Creating two repositories, "RCL" and "CGW"
sudo mkdir /var/svn-repos/
sudo svnadmin create --fs-type fsfs /var/svn-repos/RCL
sudo svnadmin create --fs-type fsfs /var/svn-repos/CGW
Set permissions
sudo groupadd subversion
sudo addgroup pmn subversion
sudo addgroup pi subversion
sudo addgroup someOtherSVNuser subversion
sudo chown -R www-data:subversion /var/svn-repos/*
sudo chmod -R 770 /var/svn-repos/*
Add to /etc/apache2/mods-available/dav_svn.conf (so HTTP can be used, through Apache (and also enabling browsing from a web browser)):
sudo vi /etc/apache2/mods-available/dav_svn.conf
<Location /svn>
DAV svnSVNParentPath /var/svn-repos
AuthType Basic
AuthName "Subversion Repo"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
Add an SVN user
sudo htpasswd -c /etc/apache2/dav_svn.passwd jeremy
somePassword
Add some content to a repository (locally on the server)
mkdir /home/pi/projects
mkdir /home/pi/projects/helloworld
cd /home/pi/projects/helloworld
sudo nano main.cpp
sudo svn import -m 'Some first checked in file' /home/pi/projects/helloworld/ file://localhost/var/svn-repos/CGW
Test in browser (Raspberry Pi server at IP address 192.168.0.120):
http://192.168.0.120/svn/CGW/
2015-12-01
Drawing a line in Inkscape
The key is double clicking when at the second point of the line (otherwise, nothing will be drawn).
Do:
- Select the Bezier drawing tool. In later versions of Inkscape there is also a help text for this tool that indicates that it can be used to draw straight lines.
- Left click for the first point of the line.
- Drag to the position of the second point of the line.
- Double click.
2015-01-02
Installing VLC media player and MPlayer on Raspberry Pi and Ubuntu
sudo apt-get install software-properties-common
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:videolan/stable-daily
sudo apt-get update
sudo apt-get install mplayer vlc
The first two lines are for installing add-apt-repository. It may not be strictly necessary to install both (add-apt-repository is only in one of them, depending on particular versions of the operating system), but in this way it is guaranteed to work.
2014-12-05
Breaking into PowerShell
Notes for climbing the steep PowerShell learning curve...
Commonly used cmdlets (use Get-Alias to get the list of all aliases):
- Get-ChildItem. Aliases: ls, dir, and gci
- Get-Content. Aliases: cat, gc, and type
- Get-Help. Using the option -full will output examples of use for the cmdlet in question.
- Get-WmiObject. Alias: gwmi. In PowerShell 1.0 it was largely the only way to access remote computers.
- Format-List. Effectively reverse rows and columns (in output).
- Get-Location. Aliases: pwd and gl
- Get-Member. Alias: gm
- Get-Process. Aliases: gps and ps
- Group-Object. Alias: group
- Measure-Command. For timing.
- Measure-Object. Alias: measure
- New-Item. Alias: ni (and mkdir with parameter -ItemType "Directory"). For instance, create a new file, new folder or registry entry.
- New-Object.
- Out-GridView. Open GUI window with the fields as columns and objects as rows. The columns can be interactively sorted and the clipboard works with the usual shortcut Ctrl + C, including disjoint selected rows!. Alias: ogv
- Select-Object. Effectively choose another subset of fields from an object than the default (e.g. for the ultimate goal of an output). Alias: select
- Set-Location. Sets the current working location. Aliases cd, chdir, and sl
- Sort-Object. Alias: sort
- Test-Path. Test if the syntax for a path is correct. Useful when dealing with user input.
- Where-Object. Used to filter (get a subset of piped objects). A common idiom is Where-Object {$_ -match '\d{3}[-|\s]\d{3}[-|\s]\d{3}$'}, where what is between the two single quotes is a regular expression. Aliases: where and ?
- Write-Output. If the command is the last command in the pipeline, the objects are displayed in the console. Aliases: echo and write
wc
Equivalent to Linux' wc (used on a directory listing in this example):
Get-ChildItem | Measure-Object | Select-Object -ExpandProperty Count
Using aliases:
dir | measure | select -ExpandProperty Count
Example: get desired information from the running processes on the computer
Get-Process returns a (very long) list of running processes on the computer. Assume we are interested in the processes that take up a lot of memory and that are potentially leaking (Private Bytes is the proper quantity for this). First explore the different kind of values with Get-Member:
Get-Process | Get-Member
The field "PrivateMemorySize" seems to be what is called "Private Bytes".
Use Where-Object to only get the subset of processes that take up more than about 1 MB:
Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000}
This returns some processes with eight different kinds of fields (or at least that is how it appears in the output on the screen), but not private bytes. Say we still want the process ID and process name, but also private bytes and the full path to the executable. Use Select-Object to get those four fields instead of the eight defaults (the four names are from the output of Get-Member, above):
Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path
We can sort by any of the four fields:
Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path | Sort-Object -Property PrivateMemorySize
When this is output to the screen, it is way too wide. To get more readable output we can effectively reverse rows and columns with Format-List:
Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path | Sort-Object -Property PrivateMemorySize | Format-List
Alternatively, we can get the output into a GUI window using cmdlet Out-GridView:
Get-Process | Where-Object {$_.PrivateMemorySize -gt 1000000} | Select-Object Id, PrivateMemorySize, Name, Path | Sort-Object -Property PrivateMemorySize | Out-GridView
The GUI window is quite sophisticated. For instance, using Add criteria, all instances of svchost can be excluded from the displayed processes.
Using aliases and the fact that the parameter to Sort-Object is positional, it can be shortened to:
ps | where {$_.PrivateMemorySize -gt 1000000} | select Id, PrivateMemorySize, Name, Path | sort PrivateMemorySize | Format-List
and
ps | where {$_.PrivateMemorySize -gt 1000000} | select Id, PrivateMemorySize, Name, Path | sort PrivateMemorySize | ogv
, respectively.
On my system the last items in the output was:
Id : 448
PrivateMemorySize : 56143872
Name : powershell
Path : C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
Id : 3636
PrivateMemorySize : 90882048
Name : CCC
Path : C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static\ccc.exe
Id : 4952
PrivateMemorySize : 349118464
Name : opera
Path : D:\Program Files (x86)\Opera1051\opera.exe
Id : 2648
PrivateMemorySize : 630624256
Name : firefox
Path : D:\Program Files (x86)\Mozilla Firefox27\firefox.exe
Firefox took up 601 MB, the Opera web browser 332 MB, some videodisplay thingy 87 MB and PowerShell itself 54 MB.
2013-02-26
M95C512 is a 64 kilobyte EEPROM
M95C512 is a standard serial EEPROM in STMicroelectronics's (ST) M95 series and is a 512 kbit (64 kilobyte) serial SPI bus EEPROM.
The datasheet (PDF) is at http://www.st.com/web/en/resource/technical/document/datasheet/CD00048102.pdf. Here it is listed as M95512-W, M95512-R, M95512-DR, and M95512-DF (the difference is in the lowest supply voltage they accept; they have 5.5 V as their upper limit).
So why did I post this information? Because I am working every day with a device that employs a M95C512!
2012-04-15
The scripting story for .NET
Promising references:
- Make your .NET application support scripting - a practical approach
- Scripting for .NET
- Script Happens .NET "Writing applications that host a script engine to enable people to write scripts to customize and extend applications has proven to be very successful"
- Using .NET to make your Application Scriptable "The Object Model, Host Application & Script Editor"
Finding the scripting story of .NET (and what to actually do in order to implement scripting in a .NET application) turns out to be very hard. Part of the reason may be that scripting is not in vogue anymore, even though it is (still) important for any successful desktop or server application - sooner or later there will be a need to automate things, instead of tediously doing things only through the user interface.
An indication of the sad state of affairs is that Stack Overflowers will completely misunderstand a question of this kind and think it is about choosing a particular scripting language (PowerShell, Iron Python, etc.) when the question is about how to make an application scriptable and define/implement an object model. They will completely fail to understand what an object model is, even if it is explained in the question (often they will not read such an explanation, but immediately associate "scripting" or "scriptable" with "scripting language").
In the 1990s both Apple and Microsoft had focus on scripting. Apple with the Open Scripting Architecture (OSA) and Microsoft with COM. Both had "object models", a term that is often misunderstood by the ignorant or those that think in terms of a programming language for implementing an application. An object model is how an external application or script (internal or external) sees and interact with the application. A class in the object model represent something in the application and roughly represent the same thing as from the user interface.
For instance, in many cases there is a document class that represent a document in the application. The document class will often have a property named "title" (property is also an object model term and is not to be confused with, say, properties in binary components in COM or .NET). Changing the "title" property of a document in an external script will have the side effect of changing the title in the running instance of the application, corresponding to (in this case) of the user doing a Save As operation to save the document in a new file and as a result changing the title of the document.
Microsoft has implemented object models in their Office Suite of applications.
With the advent of .NET there was not much fanfare regarding scripting, but the scripting story for .NET may actually have been summarised by the MSDN Magazine article "Scripting and .NET: Visual Studio for Applications Provides Customized Scripting Facilities for Your .NET Project" (2002-08):
In the past, the Microsoft Active Scripting architecture has allowed you to make your applications extensible. But it came with some drawbacks. You couldn't call into DLLs; you had to use COM interfaces. The scripts were not compiled, so they ran more slowly than they otherwise might, and a number of objects had to ride along with the script. To solve these problems and make extensibility easier to attain, Visual Studio for Applications (VSA) was introduced.
The Microsoft® Active Scripting architecture was a COM-based solution that met many of these criteria, but it wasn't perfect."
The Microsoft .NET platform has a set of classes that offers the benefits of Active Scripting without the drawbacks. This set of classes, named Visual Studio® for Applications (VSA), provides a pluggable IDE and debugger for Visual Basic® .NET."
But that is 10 years ago, so where are we now?
VSA, though, is not even contained in Wikipedia.
Further reading:
- Introducing Visual Studio for Applications (2001-01-16). "... have probably been wondering what role script plays in the .NET world", "Customization in a .NET World"
To Be Continued...
