Skip to content

Instantly share code, notes, and snippets.

View razius's full-sized avatar

Silviu Tantos razius

View GitHub Profile
@razius
razius / rounding_decimals.md
Created January 19, 2016 14:34 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

### Keybase proof
I hereby claim:
* I am razius on github.
* I am razius (https://keybase.io/razius) on keybase.
* I have a public key whose fingerprint is D175 3880 87B6 AE73 BE5A E9F9 0C84 8540 AB33 4BF7
To claim this, I am signing this object:
#!/bin/bash
# Check if DBUS is started and if not start it.
if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
eval "$(dbus-launch --sh-syntax --exit-with-session)"
fi
# Touchpad tweaks
synclient AreaTopEdge=5000
@razius
razius / chrome-refresh.sh
Last active November 6, 2018 13:50
Watches the folder or files passed as arguments to the script and when detects a change it automatically refreshes the current selected Chrome tab or window.
#!/bin/bash
#
# Watches the folder or files passed as arguments to the script and when it
# detects a change it automatically refreshes the current selected Chrome tab or
# window.
#
# http://razius.com/articles/auto-refreshing-google-chrome-on-file-changes/
#
# Usage:
# ./chrome-refresh.sh /folder/to/watch /some/folder/file_to_watch.html
@razius
razius / run-once.sh
Last active December 26, 2015 12:19
Check if a command is running already, if not start it with the provided arguments.
#!/bin/bash
# Check if a command is running already, if not start it with the provided arguments.
#
# Example:
# This will check if thunar is already running if not it will start it with the --daemon argument.
# ./run-once.sh thunar --daemon
#
# I use it for my awesomewm autostart script which is available here:
# https://github.com/razius/awesomewm/blob/master/autostart.sh