Skip to content

Instantly share code, notes, and snippets.

View razius's full-sized avatar

Silviu Tantos razius

View GitHub Profile
#!/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 / simple_wsgi.py
Created September 24, 2014 14:45
A very simple web framework and application
import re
import traceback
class wsgiapplication(object):
"""Base class for wsgiapplication."""
def __init__(self, environ, start_response):
self.environ = environ
self.start = start_response
### 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 / 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
@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

@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
import md5
import time
# Python 2 and 3 compatible but requires the six external library.
from six.moves import urllib
from django.http import Http404
from django.conf import settings
from django.http import HttpResponsePermanentRedirect
from django.utils.http import http_date
#!/bin/bash
PROJECT_PATH="$HOME/Desktop/unisport"
GIT_REPO="git@github.com:unisport/unisport.git"
git-remote-url-reachable() {
git ls-remote $GIT_REPO HEAD > /dev/null 2>&1
}
aws-configured() {
aws sts get-caller-identity > /dev/null 2>&1