Skip to content

Instantly share code, notes, and snippets.

@tux-00
tux-00 / gist:9508092
Last active September 10, 2015 15:19
Format bytes to kb Mb Gb or Tb automaticaly.
<?php
function formatBytes($size, $precision = 2)
{
if($size== 0) {
return 0;
}
$base = log($size) / log(1024);
$suffixes = array('o', 'kb', 'Mb', 'Gb', 'Tb');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
@tux-00
tux-00 / emu_1212m_drivers.md
Last active March 20, 2017 12:57
Install EMU 1212m drivers on Linux (Fedora)
dnf install alsa-firmware
shutdown -r now
@tux-00
tux-00 / disable_mouse_accel.md
Last active March 20, 2017 12:55
Disable mouse acceleration
xset m default
@tux-00
tux-00 / bumblebee_dual_screen_bug.md
Last active March 20, 2017 13:00
How to fix Bumblebee dual screen bug
@tux-00
tux-00 / cancel_commit.md
Last active March 20, 2017 13:04
Cancel a specific commit

Revert one commit

git revert {sha}

Revert commit x to y

git revert {sha}..{sha}

@tux-00
tux-00 / cat_without_comment.md
Last active March 20, 2017 12:53
Cat without comment
cat /etc/squid/squid.conf | egrep -v "(^#.*|^$)"
@tux-00
tux-00 / convert_date_to_timestamp.py
Last active March 20, 2017 13:01
Convert date to POSIX timestamp
dt = datetime.datetime.strptime("2015-01-08T01:50:11.719671Z", "%Y-%m-%dT%H:%M:%S.%fZ")
dt.timestamp()
@tux-00
tux-00 / test_strings.py
Created March 17, 2017 13:35
Test python3.6 string concatenation performance
def test1():
g = 'gg'
s = 'toto' + g
def test2():
g = 'gg'
s = 'toto%s' % g
def test3():
g = 'gg'
@tux-00
tux-00 / git_change_commit_author.md
Created March 20, 2017 12:41
Change Git commit author
git rebase -i <earliercommit>
git commit --amend --author="Author Name <[email protected]>"
git rebase --continue