Skip to content

Instantly share code, notes, and snippets.

@deevis
Created August 5, 2019 21:52
Show Gist options
  • Save deevis/ded145e4c3fa3e493530e1f1a7bd2bb0 to your computer and use it in GitHub Desktop.
Save deevis/ded145e4c3fa3e493530e1f1a7bd2bb0 to your computer and use it in GitHub Desktop.
Takes a byte[] and a width to set number of display columns and dumps the bytes out in a grid
decdump = ->(bytes,width) {bytes.each_with_index{|b,i| print " [#{i.to_s.rjust(3,' ')}] "
if i%width==0; print "#{b.to_s.rjust(3,' ')} "; puts "" if (i+1) % width == 0};nil}
@deevis
Copy link
Author

deevis commented Aug 5, 2019

decdump.call(bytes, 8)

[ 0] 167 177 44 17 11 43 121 198
[ 8] 218 22 117 235 34 79 110 131
[ 16] 50 72 229 225 5 34 230 188
[ 24] 70 220 76 230 109 179 175 195
[ 32] 15 211 145 90 211 218 14 98
[ 40] 183 224 50 127 160 85 0 10
[ 48] 62 87 250 128 229 236 55 241
[ 56] 102 241 123 81 101 110 12 135
[ 64] 68 150 235 181 211 173 112 123
[ 72] 22 152 108 14 87 85 88 53
[ 80] 27 84 205 222 248 227 132 35
[ 88] 234 254 176 117 232 169 113 159
[ 96] 218 7 49 15 128 82 150 148
[104] 201 166 127 128 168 20 127 137
[112] 192 108 96 18 242 46 47 8
[120] 144 151 143 225 2 113 180 172
[128] 161 24 32 10 12 187 209 116
[136] 158 97 168 121 234 160 233 105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment