Skip to content

Instantly share code, notes, and snippets.

View tbielawa's full-sized avatar
💭
bitmath!

Tim Case tbielawa

💭
bitmath!
View GitHub Profile
@tbielawa
tbielawa / ubuntu-add-bitmath.sh
Created July 3, 2016 13:48
More details in the blog post announcement: https://blog.lnx.cx/?p=954
sudo add-apt-repository ppa:tbielawa/bitmath
sudo apt-get update
sudo apt-get install python-bitmath
@tbielawa
tbielawa / linux-compile-run-request-code.sh
Last active March 14, 2016 20:34
Reading block device sizes in python - More in the blog post: https://blog.lnx.cx/?p=678
$ gcc ./linux-request-code.c
$ ./a.out
Block count request code: 0x80081272
@tbielawa
tbielawa / epel-6-sclpy27-x86_64.cfg
Last active August 29, 2015 14:10
mock SCL py27 configuration
config_opts['root'] = 'epel-6-sclpy27-x86_64'
config_opts['target_arch'] = 'x86_64'
config_opts['legal_host_arches'] = ('x86_64',)
config_opts['chroot_setup_cmd'] = 'install @buildsys-build scl-utils-build python27-build'
config_opts['dist'] = 'el6' # only useful for --resultdir variable subst
# beware RHEL use 6Server or 6Client
config_opts['releasever'] = '6'
config_opts['yum.conf'] = """
[main]
@tbielawa
tbielawa / bitmath-examples.py
Created September 29, 2014 01:38
bitmath-1.0.8-1: Examples
>>> import bitmath
>>> a_big_kib = bitmath.KiB(102400)
>>> print "Default:", a_big_kib, "| Best-prefix:", a_big_kib.best_prefix()
Default: 102400.0 KiB | Best-prefix: 100.0 MiB
>>> print (a_big_kib/3.0).format("{value:.3f}/{unit}")
34133.333/KiB
>>> print a_big_kib.bits, a_big_kib.system
@tbielawa
tbielawa / thinkpad-t440s-dmidecode
Created June 17, 2014 18:49
See the blog post for more information: https://blog.lnx.cx/?p=541
$ sudo dmidecode -t 16
# dmidecode 2.12
SMBIOS 2.7 present.
Handle 0x0005, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 12 GB
@tbielawa
tbielawa / python-bitmath.yum.info
Created March 27, 2014 16:37
python-bitmath - Now available in Fedora repositories! More at https://blog.lnx.cx/?p=550
$ yum info python-bitmath
Available Packages
Name : python-bitmath
Arch : noarch
Version : 1.0.4
Release : 1.fc20
Size : 23 k
Repo : updates/20/x86_64
Summary : Aids representing and manipulating sizes in various prefix
: notations
@tbielawa
tbielawa / 01-synaptics.conf
Created March 20, 2014 17:13
Tuning the Thinkpad T440s touchpad - See more at: https://blog.lnx.cx/?p=541
# /etc/X11/xorg.conf.d/01-synaptics.conf
Section "InputClass"
Identifier "t440 top buttons"
MatchDriver "synaptics"
# right btn|middle btn
Option "SoftButtonAreas" "60% 0 0 0 40% 60% 0 0"
Option "HorizHysteresis" "30"
Option "VertHysteresis" "30"
Option "PalmDetect" "1"
>>> from bitmath import *
>>> four_mibibits = Mib(4)
>>> four_mibibits.to_kB()
kB(524.288)
>>> ninty_nine_bits = Bit(99)
>>> a_small_exbibyte = ninty_nine_bits.to_EiB()
>>> from bitmath import *
>>> GiB(42) * 3
GiB(126.0)
>>> Bit(9) + Byte(3)
Bit(33.0)
>>> exbi = EiB(0.6)