Skip to content

Instantly share code, notes, and snippets.

Avatar

Silviu Tantos razius

View GitHub Profile
@razius
razius / chrome-refresh.sh
Last active Nov 6, 2018
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.
View chrome-refresh.sh
#!/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 / rounding_decimals.md
Created Jan 19, 2016 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?
View rounding_decimals.md

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

@razius
razius / run-once.sh
Last active Dec 26, 2015
Check if a command is running already, if not start it with the provided arguments.
View run-once.sh
#!/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
View gist:d12e8e120aa8d626fb44
### 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:
@razius
razius / simple_wsgi.py
Created Sep 24, 2014
A very simple web framework and application
View simple_wsgi.py
import re
import traceback
class wsgiapplication(object):
"""Base class for wsgiapplication."""
def __init__(self, environ, start_response):
self.environ = environ
self.start = start_response
View autorun.sh
#!/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
You can’t perform that action at this time.