Skip to content

Instantly share code, notes, and snippets.

View greezybacon's full-sized avatar

Jared Hancock greezybacon

View GitHub Profile
@liabru
liabru / json-limit-precision.js
Last active May 3, 2023 07:45
Limit precision of floating point numbers in a JSON string in JavaScript
var testObject = {
pi: Math.PI,
e: Math.E,
one: 1,
x: 1.5,
str: "1.2345"
};
var places = 2,
json = JSON.stringify(testObject, function(key, value) {
@greezybacon
greezybacon / overloaded.py
Created June 21, 2012 20:51
Python overloaded method decorator
class overloaded(object):
"""
Simple (well, simple is relative) tool to allow for overloaded methods
in Python. Overloaded methods are methods with the same name that
receive different types of arguments. Statically typed languages such as
C++ support overloaded methods at compile time; however, dynamically
typed languages such as Python cannot support such methods, because no
type hints can be specified in the function definition.
This class operates as a decorator and allows for a cascaded design of
@skarllot
skarllot / bashrc.sh
Last active January 4, 2023 22:44
Default Bash prompt (bashrc PS1)
# Each distribution default Bash prompts
# Gentoo (/etc/bash/bashrc)
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
fi