Skip to content

Instantly share code, notes, and snippets.

View 4e1e0603's full-sized avatar
🎯
I may be slow to respond.

David Landa 4e1e0603

🎯
I may be slow to respond.
  • Prague, Czech Republic
View GitHub Profile
// Test Gist
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0; // EXIT_SUCCESS
}
class A(object):
def __init__(self):
self.__var = 1
def __private(self):
print("--private--")
a = A()
print(A.__dict__.keys())
@4e1e0603
4e1e0603 / read_text.c
Last active September 20, 2015 10:33
/**
Reads the content and returns it as a string.
@param filename
@returns string
*/
const char * read_text(const char * filename)
{
assert(NULL != filename);
FILE * fp;
fn main() {
println!("Hello, World!")
}
@4e1e0603
4e1e0603 / docx_content.py
Last active August 29, 2015 14:22
Získání obsahu Word dolumentu
def get_docx_paragraphs_content(path, delimiter="\n"):
"""
Funkce vrací obsah odstavců Word dokumentu.
:path: Cesta k Word dokumentu.
:delimiter: Oddělovací znak jednotlivých odstavců ve výstupním řetězci.
:returns paragraphs: Vrací obsah odstavců jako řetězec.
"""
import os
import zipfile
from xml.etree.ElementTree import XML
@4e1e0603
4e1e0603 / pair.hxx
Created December 3, 2015 11:41
C++ generic `pair` type example.
///
/// uetoyo
///
template<typename F, typename S>
class Pair
{
public:
inline Pair(F first, S second) : _first(first), _second(second)
{
}
@4e1e0603
4e1e0603 / ClearScreenPythonInterpreter.md
Last active December 4, 2015 12:37
Clear the Python interpreter screen

Clear the screen with the running Python interpreter.

...as a function

def clear_screen(): import os; os.system('cls' if os.name=='nt' else 'clear')

...as a lambda expression with explicit import statement

@4e1e0603
4e1e0603 / num_cpu_cores.py
Created December 7, 2015 11:42 — forked from cgoldberg/num_cpu_cores.py
Find the number of CPU cores (Linux)
def num_cpu_cores():
with open('/proc/cpuinfo') as f:
return f.read().count('processor')
@4e1e0603
4e1e0603 / UsingPropertiesInPython.md
Last active April 4, 2021 15:14
Using Properties In Python

Jak a proč v Pythonu využívat properties

V tomto článku si vysvětlíme k čemu jsou properties, jak jich využít, jaké výhody přináší a proč bychom je měli používat namísto přímého přístupu k proměnným nebo namísto tzv. get/set metod, které se běžné používají v jiných OOP jazycích.


V následujícím příkladu vytvoříme třídu A s jedním instančním atributem x a výchozí hodnotou 0.

@4e1e0603
4e1e0603 / alchemical_model.py
Created December 18, 2015 14:18 — forked from harvimt/alchemical_model.py
SQLAlchemy to/from PyQt Adapters
#!/usr/bin/env python2
#-*- coding=utf-8 -*-
# © 2013 Mark Harviston, BSD License
from __future__ import absolute_import, unicode_literals, print_function
"""
Qt data models that bind to SQLAlchemy queries
"""
from PyQt4 import QtGui
from PyQt4.QtCore import QAbstractTableModel, QVariant, Qt
import logging # noqa