We'll use Powershell. Why? *1
#!/bin/bash
if [ "$UID" -ne "0" ]
then
echo "You are not root, exiting.."
exit 1
fi
apt update && apt -y upgrade && apt install -y wget
URL="https://packages.microsoft.com/config/debian/"
URL+="11/packages-microsoft-prod.deb"
wget $URL
dpkg -i packages-microsoft-prod.deb
apt update
apt install -y powershell
rm -f packages-microsoft-prod.deb
--
*1) ..Well now, what shall I talk about? There are, of course, any number of things I could talk about. I could take the egotistical approach and talk about myself, elucidating all those quirks of genetics and upbringing that brought me to the place of creating Perl, as well as making a fool of myself in general. That might be entertaining, at least to me.
.."Do one thing and do it well" was the rallying cry, and with one stroke, shell programmers were condemned to a life of muttering and counting beads on strings (which in these latter days have come to be known as pipelines).. This was when I made my small contribution to saving the world. I was rolling some of those very beads around in my fingers one day and pondering the hopelessness (and haplessness) of my existence, when it occurred to me that it might be interesting to melt down some of those mystical beads and see what would happen to their Magic if I made a single, slightly larger bead out of them. So I fired up the old Bunsen burner, picked out some of my favorite beads, and let them melt together however they would. And lo! the new Magic was more powerful than the sum of its parts and parcels.
..The Amulet isn't exactly beautiful though -- in fact, up close it still looks like a bunch of beads melted together. Well, all right, I admit it. It's downright ugly. But never mind that. It's the Magic that counts.
Larry Wall
September, 1993
https://www.cs.ait.ac.th/~on/O/oreilly/perl/learn32/prf1_01.htm
.. будучи на кухне, пришла одна мысль на тему предыдущего выступления:
Я слил остатки супов в одну кастрюлю и размешал -- получилось вполне съедобно. Про историю пиццы и фруктового желе даже не стану вникать в детали -- "..из всего, что осталось". Это Perl!.. Но я пошел дальше и вывалил все три полученных блюда в одно корыто. Это (вы подумали помои?) Powershell!, решил я.
1..6 | % { 1,2,8,10,16 | % { $_ }}
1 | % { $_ ? "too much" : "not enough" }
too much
0 | % { $_ ? "too much" : "not enough" }
not enough
Для начала уясним, что echo
является синонимом Write-Output
.
Write-Host
является продвинутым аналогом Write-Output
.
write-host hi -NoNewline "welt"
Easiest way to Shuffle an Array with PowerShell
1..30 | Sort-Object {Get-Random}
https://ilovepowershell.com/2015/01/24/easiest-way-shuffle-array-powershell/
Get-Alias | out-string -stream | Select-string "wri"
Get-Command | Where {$_.NAME -match "Wri"}
https://devblogs.microsoft.com/powershell/how-does-select-string-work-with-pipelines-of-objects/
variants.ps1
$a = 1..8 | % { 2,8,10,16 | Sort-Object { Get-Random }}
$b = 1..8 | % { 2,8,10,16 | Sort-Object { Get-Random }}
$obj = @()
$n=0; gc ./kit22v.txt | `
% {
$src=$a[$n];
$dst=$b[$n];
$obj+=[pscustomobject]@{
n=$n;
name=$_;
src=$src;
dst=$dst;
}
$n++;
}
$obj | ft
Group:
n name src dst
- ---- --- ---
0 Leon Anton 2 16
1 Nikita Beljajev 16 8
2 Veronika Borzenkova 10 2
3 Nikita Faskhutdinov 8 10
4 Gleb Jagudin 8 2
5 Vladislav Kolesnikov 10 8
6 Martin-German Larin 2 16
7 Ilja Ljussin 16 10
8 Sergei Mahhalov 10 2
9 Hlib Malakhov 8 16
10 Oleksandr Melnyk 2 8
11 Kirill Nikitin 16 10
12 Daniil Okunevski 2 8
13 Oksana Ostroverh 10 2
14 Georgi Popovitš 16 10
15 Dmitri Prozorov 8 16
16 Dmitry Romanovich 8 2
17 Gleb Sahhatov 2 10
18 Kristian-Manivald Saltõkov 10 8
19 Ilya Sarbash 16 16
20 Mikhail Shmelev 16 10
21 Elizaveta Skibinskaja 10 2
22 Lev Sugakov 2 16
23 Juri Tolmatšjov 8 8
24 Aleksandr Tsakker 2 16
25 Kirill Tubiš 16 2
26 Aleksei Tšekatovski 10 10
27 Deniss Tšernjakov 8 8
28 Anastassija Varnava 8 8
29 Evgeny Zaletkin 10 2
30 Anna Žukova 2 10
99 Kirill Nelus 10 10
Example 99. Convert from based 10 to based 10 via based 2 number system
read x # level 1 (regex) validate
b=`echo "obase=2; ibase=10; $x" | bc`
d=`echo "obase=10; ibase=2; $b" | bc`
echo "x=$x 10 -> 2 $b 2 -> 10 $d"
MD to HTML with MS VSC +
Markdown All in One by Yu Zhang
Table Prettifier by Krisztian Daroczi
Markdown+Math by goessner
Google Chrome -> print to pdf -> A4, Portrait,
Margins: top, bottom .4" left, right 0", Scale 130%
[ ] Headers and Footers
[ ] Background Graphics
234567891123456789212345678931234567894123456789512345678961
--------|---------|---------|---------|---------|---------|-
MBQ
The workaround (https://github.com/microsoft/vscode/issues/38834) for this issue that I've been using is:
ansi2html.sh
* to convert it to an HTML file.
That can be done from the terminal usingcat boot.log | ./ansitohtml.sh --bg=dark > boot.html
for example.*) https://github.com/pixelb/scripts/blob/master/scripts/ansi2html.sh (also apt install gawk
)
MBP
Pythonic enough?
print('x y xy'); [[print(x, y, int(x and y)) \
for y in range(2) if True] for x in range(2)]
print('' if False else 'x y z xyz')
[[[print(x, y, z, int(x and y and z))
for z in (0, 1)]
for y in (0, 1)] for x in (0, 1)]
n=input("Arv?: ")
m=len(n)-1
for i in range(len(n)):
print(n[i]+"*10^"+str(m-i)+("+" if i!=m else ""),end='')