This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverse(){ | |
param([Int32]$b) | |
$b = (($b -band 0xf0) -shr 4) -bor (($b -band 0x0f) -shl 4) | |
$b = (($b -band 0xcc) -shr 2) -bor (($b -band 0x33) -shl 2) | |
$b = (($b -band 0xaa) -shr 1) -bor (($b -band 0x55) -shl 1) | |
$b | |
} | |
# on a 64bit machine this is an alternative to reverse() function | |
function reverse64(){ | |
param([Int32]$x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(n) => | |
let | |
swapAnyOrder = (_,from,to)=> if from = to then _ else | |
(if from < to then swap(_,from,to) else swap(_,to,from)), | |
swap = (_,from,to)=> List.Range(_,0,from) | |
&{_{to}} | |
&List.Range(_,from+1,to-from-1) | |
&{_{from}} | |
&List.Range(_,to+1) | |
in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= List.Generate( | |
()=> [ | |
can_expand=true, | |
level =1, | |
input =json, | |
output =[level.0=Record.FieldNames(json){0}] | |
], | |
each [can_expand], | |
each [ | |
can_expand =Record.FieldValues([input]){0} is record, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expandableColumns = (_) => List.Accumulate( | |
Table.ColumnNames(_), | |
{}, | |
(s,c)=>s&(if Type.Is(Value.Type(Record.Field(_{0},c)), type record) | |
or Type.Is(Value.Type(Record.Field(_{0},c)), type list) | |
then {c} | |
else {} | |
) | |
), | |
columnHasConsistentType = (T,Cname) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverse = (x) => | |
Number.Mod(Number.BitwiseAnd((x* 0x0202020202),0x010884422010),1023), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverse32 = (x) => | |
let | |
b0 = Number.BitwiseAnd(x,0xff), | |
b1 = Number.BitwiseShiftRight(Number.BitwiseAnd(x,0xff00),8), | |
b2 = Number.BitwiseShiftRight(Number.BitwiseAnd(x,0xff0000),16), | |
b3 = Number.BitwiseShiftRight(Number.BitwiseAnd(x,0xff000000),24) | |
in | |
Number.BitwiseOr( | |
Number.BitwiseOr( | |
Number.BitwiseShiftLeft(reverse(b0),24), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calculateCRClookup = (divident)=> | |
let | |
// move divident byte into MSB of 32Bit CRC | |
curByte = Number.BitwiseShiftLeft(divident,24) | |
in | |
List.Accumulate({0..7}, | |
curByte, | |
(_curByte,_)=> | |
let | |
// if MSB set, shift left and XOR with polynomial = 0x4C11DB7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List.Swap = (_,_from as number ,_to as number) => | |
let | |
from = List.Min({_from,_to}), | |
to = List.Max({_from,_to}) | |
in if from=to then _ else | |
List.Range(_,0,from) | |
&{_{to}} | |
&List.Range(_,from+1,to-from-1) | |
&{_{from}} | |
&List.Range(_,to+1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(url) => | |
let | |
BufferedWithMetadata = (binary)=>(try Binary.Buffer() otherwise null) meta Value.Metadata(binary), | |
response = BufferWithMetadata(Web.Contents(url,[ManualStatusHandling={404}])), | |
out = if Value.Metadata(response)[Response.Status]=404 | |
then null | |
else response | |
in | |
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(hexString as text) | |
=> Expression.Evaluate(“0x”&hexString) |
OlderNewer