The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,152 other subscribers

Archive for October 13th, 2021

Raspberry Pi Turn Tv On/Off CEC – Tim Leland

Posted by jpluimers on 2021/10/13

[WayBack] Raspberry Pi Turn Tv On/Off CEC – Tim Leland (with some quote fixes) via [Archive.is] Brad Fitzpatrick on Twitter: “lol tear (from )… “:

Install cec-utils

Once everything is installed you should be able to control the tv using the command below:

  • Turn tv on: echo 'on 0' | cec-client -s -d 1
  • Turn tv off: echo 'standby 0' | cec-client -s -d 1
  • Set active source: echo 'as' | cec-client -s -d 1
  • Tv status: echo 'pow 0' | cec-client -s -d 1

Troubleshooting Tips:

  • Make sure your tv supports cec and that it is enabled. Tv manufactures call CEC by different names so you may have to do some research depending on your brand.
  • Make sure you are using a new hdmi cable that is at least HDMI 1.2a

Different names for HDMI CEC

  • Samsung – Anynet+
  • Sony – BRAVIA Link or BRAVIA Sync
  • Sharp – Aquos Link
  • Hitachi – HDMI-CEC
  • AOC – E-link
  • Pioneer – Kuro Link
  • Toshiba – Regza Link or CE-Link
  • Onkyo – RIHD (Remote Interactive over HDMI)
  • LG – SimpLink
  • Panasonic – VIERA Link or HDAVI Control or EZ-Sync
  • Philips – EasyLink
  • Mitsubishi – NetCommand for HDMI
  • Runco International – RuncoLink

Credits: http://raspberrypi.stackexchange.com/questions/7054/cec-wake-up-command

Related:

–jeroen

Read the rest of this entry »

Posted in *nix, *nix-tools, Development, Hardware Development, Hardware Interfacing, HDMI, Power User, Raspberry Pi, Software Development | Leave a Comment »

Some links on xargs simulation in PowerShell

Posted by jpluimers on 2021/10/13

On nx, I’m used to xargs which allows to convert from a pipe of output into arguments passed to a command. This is useful, as many commands only accept arguments as parameters.

In PowerShell, you can usually avoid an xargs equivalent because commandlet output is a stream of objects that you can post-process using . I for instance used that in PowerShell: recovering from corrupt empty *.nupkg files after a disk was accidentally full during update.

Here are some xargs equivalency examples:

  • [WayBack] PowerShell tips for bash users, part 1 • Five

    xargs

    Xargs is one of the most powerfull UNIX commands. It is used to build and execute command lines from standard input. For example:
    $ cat dirs | xargs mkdir
    will use cat to take the strings (be it newline or blank character separated) from file ‘dirs’ and pass them through pipe to xargs which will then send one by one line as argument to mkdir which will then create those dirs or complain if those are existent.

    PowerShell equivalent:

    PS> cat dirs | %{mkdir $_}

    There is no ‘xargs’ command in PS, but you can use ‘foreach ‘ loop and pass the piped variable ‘$_’ to the mkdir. Shorthand for ‘foreach’ is ‘%’. This time also only newlines will separate the strings apart. If multiple strings separated by blanks are found in same line, mkdir will create a directory with blanks in the name, while we must quote to have the same in bash:

    $ cat dirs | sed 's|^|"|g' | sed 's|$|"|g' |xargs mkdir

  • [WayBack] What’s the equivalent of xargs in PowerShell? – Stack Overflow

    Q

    The POSIX-defined xargs command takes all of the items it receives from standard input and passes them as command-line arguments to the command it receives on it’s own command line. E.g: grep -rn "String" | xargs rm.

    What’s the equivalent in PowerShell?

    The following questions all ask this:

    but there is no correct answer because all the answers either use ForEach-Object, which will process items one-at-a-time (like xargs -n1) which gets the desired result for the examples given, or store the intermediate result in a variable, which offends my functional commandline-fu.

    A

    There are two ways that I’ve found. The first is probably more idiomatic PowerShell, and the second is more true to the pipe-based spirit of xargs.

    As an example, let’s say we want to pass all our cat pics to myapp.exe.

    Method #1: Command substitution

    You can do something similar to using $(command substitution) in sh by embedding your pipeline in the command string:

    &"myapp.exe" @(Get-ChildItem -Recurse -Filter *.jpg | Another-Step)

    The @(...) creates an array from the command inside it, and PowerShell automatically expands arrays passed to & into seperate command-line parameters.

    However, this does not really answer the question, because it will only work if you have control over the command you want to pass to, which may not be the case.

    Method #2: True piping

    You can also construct a “double pipeline” by having a sub-expression to pipe your objects, collecting them to an array, and then piping the array to your final command.

    ,@(Get-ChildItem -Recurse -Filter *.jpg | Another-Step) | %{&"myapp.exe" $_}

    The @(...) as before collects the items into an array, and the array is then piped to the final command which is invoked using % (ForEach-Object). Ordinarily, this would then loop over each item individually, because PowerShell will automatically flatten the array when it’s piped, but this can be avoided by prepending the , operator. The $_ special variable is then used as normal to embed the passed array.

    So the key is to wrap the pipeline you want to collect in ,@(...), and then pipe that to something in %{...}.

References

–jeroen

Posted in *nix, *nix-tools, bash, CommandLine, Development, Power User, PowerShell, PowerShell, Scripting, Software Development, xargs | Leave a Comment »

BEHIND THE CODE: The one who created languages – YouTube

Posted by jpluimers on 2021/10/13

Anders Hejlsberg: software legend.

–jeroen

Posted in .NET, C#, Development, Pascal, Software Development, Turbo Pascal, TypeScript | Leave a Comment »

 
%d bloggers like this: