Skip to content

Instantly share code, notes, and snippets.

@zenubis
zenubis / rclone_exclude_list.txt
Last active February 3, 2025 16:02
List of file names to be excluded from rclone/rsync copying for common macOS and windows system files.
$RECYCLE.BIN
$Recycle.Bin
.AppleDB
.AppleDesktop
.AppleDouble
.com.apple.timemachine.supported
.dbfseventsd
.DocumentRevisions-V100*
.DS_Store
.fseventsd
def round(n, m):
return ((n+(m-1)) / m) * m
for x in xrange(0,50):
print x, "=>", round(x, 10)
def MakeDirectory(path):
try:
os.makedirs(path)
except OSError, e:
if e.errno == 17: #already exist
pass
else:
print e
raise e;
// Taken from http://www.codeproject.com/Articles/10500/Converting-C-enums-to-strings
// File name: "EnumToString.h"
#undef DECL_ENUM_ELEMENT
#undef BEGIN_ENUM
#undef END_ENUM
#ifndef GENERATE_ENUM_STRINGS
#define DECL_ENUM_ELEMENT( element ) element
#define BEGIN_ENUM( ENUM_NAME ) typedef enum tag##ENUM_NAME
#define BIT_SET(variable, flag) (variable) |= (flag)
#define BIT_TEST(variable, flag) (((variable) & (flag)) == (flag))
#define BIT_REMOVE(variable, flag) ((variable &= ~(flag)))
@zenubis
zenubis / MakeString.c
Created May 15, 2014 03:08
A macro to make literal string out of everything you type into it
// double macro expansion to make int to const string
// usage, printf("number of lines in this file " MAKE_STRING(42));
#define S(x) #x
#define MAKE_STRING(x) S(x)
#define STR__LINE__ MAKE_STRING(__LINE__) // __LINE__ as a string
@zenubis
zenubis / enum.py
Created April 8, 2014 03:09
python enum
#taken from http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python
def enum(**enums):
return type('Enum', (), enums)
# which is used like so:
#
#>>> Numbers = enum(ONE=1, TWO=2, THREE='three')
#>>> Numbers.ONE
#1
#>>> Numbers.TWO
@zenubis
zenubis / python_class_example.py
Last active August 29, 2015 13:57
example of a class in python
class BGM(object):
def __init__(self, _enum, _filename, _loop):
self.enum = _enum;
self.filename = _filename;
self.loop = _loop;
def __repr__(self):
return self.__str__()
def __str__(self):
@zenubis
zenubis / python_chdir
Last active August 29, 2015 13:57
python code to change to the directory where the script resides
#change to the directory where the script resides
os.chdir(os.path.dirname(os.path.abspath(__file__)));