Skip to content

Instantly share code, notes, and snippets.

@jonschoning
Last active January 15, 2023 21:33
Show Gist options
  • Save jonschoning/8916f1a54761b6495c653658023426a9 to your computer and use it in GitHub Desktop.
Save jonschoning/8916f1a54761b6495c653658023426a9 to your computer and use it in GitHub Desktop.

Revisions

  1. jonschoning revised this gist Jan 15, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions hfmt.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    xfmt=lambda v,w=2,j=' ':hfmt("{:x}".format(v),w,j)
    bfmt=lambda v,w=4,j=' ':hfmt("{:b}".format(v),w,j)
    #xfmt("{:x}".format(0xAA))
    #bfmt("{:b}".format(0XAA))
    #xfmt(0xAA)
    #bfmt(0XAA)
  2. jonschoning revised this gist Jan 15, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion hfmt.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    xfmt=lambda v,w=2,j=' ':hfmt("{:x}".format(v),w,j)
    bfmt=lambda v,w=4,j=' ':hfmt("{:b}".format(v),w,j)
    #hfmt("{:x}".format(0xAA))
    #xfmt("{:x}".format(0xAA))
    #bfmt("{:b}".format(0XAA))
  3. jonschoning revised this gist Jan 15, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions hfmt.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    bfmt=lambda s,w=4,j=' ':hfmt(s,w,j)

    hfmt("{:x}".format(5<<36)) # '50 00 00 00 00'
    bfmt("{:b}".format(5<<36)) # '0101 0000 0000 0000 0000 0000 0000 0000 0000 0000'
    xfmt=lambda v,w=2,j=' ':hfmt("{:x}".format(v),w,j)
    bfmt=lambda v,w=4,j=' ':hfmt("{:b}".format(v),w,j)
    #hfmt("{:x}".format(0xAA))
    #bfmt("{:b}".format(0XAA))
  4. jonschoning renamed this gist Jan 12, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. jonschoning revised this gist Jan 11, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions py.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    bfmt=lambda s,w=4,j=' ':hfmt(s,w,j)

    hfmt("{:x}".format(5<<36))
    bfmt("{:b}".format(5<<36))
    hfmt("{:x}".format(5<<36)) # '50 00 00 00 00'
    bfmt("{:b}".format(5<<36)) # '0101 0000 0000 0000 0000 0000 0000 0000 0000 0000'
  6. jonschoning revised this gist Jan 11, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions py.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    bfmt=lambda s,w=4,j=' ':hfmt(s,w,j)

    hfmt("{:x}".format(5<<36))
    bfmt("{:b}".format(5<<36))
  7. jonschoning revised this gist Jan 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion py.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    bfmt=lambda rs,rw=4,rj=' ':hfmt(rs,rw,rj)
    bfmt=lambda s,w=4,j=' ':hfmt(s,w,j)
    hfmt("{:x}".format(5<<36))
    bfmt("{:b}".format(5<<36))
  8. jonschoning revised this gist Jan 11, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion py.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    hfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))
    hfmt=(lambda s0,w=2,j=' ':(lambda s:j.join([s[i:i+w]for i in range(0,len(s),w)]))(s0 if len(s0)%w==0else'0'*(w-len(s0)%w)+s0))
    bfmt=lambda rs,rw=4,rj=' ':hfmt(rs,rw,rj)
    hfmt("{:x}".format(5<<36))
    bfmt("{:b}".format(5<<36))
  9. jonschoning revised this gist Jan 11, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions py.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    hfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))

    bfmt=lambda rs,rw=4,rj=' ':hfmt(rs,rw,rj)
    hfmt("{:x}".format(5<<36))
    hfmt("{:b}".format(5<<36), 4)
    bfmt("{:b}".format(5<<36))
  10. jonschoning revised this gist Jan 11, 2023. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions py.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    bfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))
    hfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))

    bfmt("{:b}".format(5<<36), 4)
    hfmt("{:x}".format(5<<36))
    hfmt("{:b}".format(5<<36), 4)
  11. jonschoning revised this gist Jan 11, 2023. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions py.py
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,3 @@
    bfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))
    bfmt("{:b}".format(5<<36), 4)
    bfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))

    bfmt("{:b}".format(5<<36), 4)
  12. jonschoning revised this gist Jan 11, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion py.py
    Original file line number Diff line number Diff line change
    @@ -1 +1,2 @@
    (lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj)) ("{:b}".format(5<<40), 4)
    bfmt=(lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj))
    bfmt("{:b}".format(5<<36), 4)
  13. jonschoning renamed this gist Jan 11, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  14. jonschoning created this gist Jan 11, 2023.
    1 change: 1 addition & 0 deletions py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    (lambda rs,rw=2,rj=' ':(lambda s,w,j:j.join([s[i:i+w]for i in range(0,len(s),w)]))(rs if len(rs)%rw==0else'0'*(rw-len(rs)%rw)+rs,rw,rj)) ("{:b}".format(5<<40), 4)