This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
int main() { | |
// Also see https://en.cppreference.com/w/cpp/feature_test | |
// and https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros | |
#ifndef __cplusplus | |
#error C++ is required | |
#elif __cplusplus < 199711L | |
puts("before C++98?!?"); | |
#elif __cplusplus < 201103L |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import csv | |
def main(): | |
csv.register_dialect('unix', lineterminator='\n', quoting=csv.QUOTE_MINIMAL) | |
with open('unix.csv', 'w') as csv_file: | |
csv_writer = csv.writer(csv_file, dialect='unix') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
"""Timed function and method decorators, portions from the python decorator module | |
Install 'termcolor' (pip install --user termcolor) for colored output. | |
""" | |
from __future__ import absolute_import, print_function, division, unicode_literals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
''' | |
Get width and height of console | |
works on Linux, OS X, Windows, Cygwin(Windows) originally retrieved from: | |
http://stackoverflow.com/questions/566746/how-to-get-console-window-width-in-python | |
updated by Doncho Nikolaev Gunchev <[email protected]> to work with python 2 and 3, make pylint happy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*usr/bin/true; A="$(readlink -f -- "$0")"; function x { rm "$A.bin"; }; trap x EXIT; g++ --std=c++14 -Wall -Wno-unused-label "$A" -o "$A.bin"; "$A.bin"; E=$?; exit $E; # */ | |
// This can be used as script - chmod +x this.cpp; ./this.cpp | |
#include <cstdio> | |
constexpr const size_t strlen_const(const char* s) { | |
return '\0' == *s ? 0 : strlen_const(s + 1) + 1; | |
} | |
int main() { | |
https://stackoverflow.com/a/25891133/1136400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
# -*- coding: utf-8 -*- | |
""" | |
>>> f1 = create_file('/tmp/test.bin') | |
>>> f2 = create_file('/tmp/test.bin') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "<stdin>", line 3, in create_file | |
OSError: [Errno 17] File exists: '/tmp/test.bin' | |
>>> f1.close() |