Skip to content

Instantly share code, notes, and snippets.

@kolodziej
kolodziej / Makefile
Last active August 29, 2015 14:10
Shell
CXX=g++
CXXFLAGS=-std=c++11 -g -DDEBUG -Wall
APPSFLAGS=-fPIC -shared
OBJS=shell_main.o shell.o
APPS=concat_application.so echo_application.so
LIBS=-ldl
TARGET=shell
all: $(OBJS) $(APPS)
$(CXX) $(CXXFLAGS) $(OBJS) $(LIBS) -o $(TARGET)
@kolodziej
kolodziej / parser.cpp
Created December 6, 2014 13:20
Cmdline parser
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
class Parser
{
private:
@kolodziej
kolodziej / app.cpp
Created November 21, 2014 22:16
Tutorial 0 for C++ modular application
#include <dlfcn.h>
#include <iostream>
int main(int argc, char ** argv)
{
if (argc == 1)
{
std::cerr << "Usage: " << argv[0] << " modules...\n";
return 1;
}
@kolodziej
kolodziej / ModuleBase.hpp
Created November 21, 2014 22:07
Tutorial 1 for C++ modular application
#ifndef MODULE_BASE_HPP
#define MODULE_BASE_HPP
class ModuleBase
{
public:
virtual void run() = 0;
};
#endif
@kolodziej
kolodziej / sqlite.cpp
Created November 18, 2014 22:57
simple sqlite client
#include <iostream>
#include <sqlite3.h>
#include <string>
int callback(void *nu, int argc, char **argv, char **colName)
{
for (int i = 0; i < argc; ++i)
{
std::cout << colName[i] << " = ";
if (argv[i])
class kontener
{
int *T, n;
public:
kontener(int n_) : T(new int[n_]), n(n_)
{
std::cout << "tworzenie kontenera o poj. " << n << " pod adresem: " << reinterpret_cast<const void*>(this) << "\n";;
}
kontener(const kontener& zrodlo) : T(new int[zrodlo.pobierz_n()]), n(zrodlo.pobierz_n())
{
@kolodziej
kolodziej / ld2_2_Obliczanie_silni_z_obsluga_parametrow_linii_polecen.cpp
Created August 26, 2014 17:09
Obliczanie silni z obsługą parametrów linii poleceń
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char ** argv)
{
int n = 0;
int silnia = 1;
cout << "\tObliczanie silni" << endl;
@kolodziej
kolodziej / ld2_1_Obliczanie_silni.cpp
Created August 26, 2014 17:08
ld2: Obliczanie silni
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char ** argv)
{
int n = 0;
int silnia = 1;
cout << "\tObliczanie silni" << endl;
#ifndef TIME_UTILITY_TPL_HPP
#define TIME_UTILITY_TPL_HPP
#include <string>
#include <sstream>
#include <chrono>
#include <ctime>
template <typename Clock, int BufSize>
std::string format_time(std::chrono::time_point<Clock> timepoint, std::string format, tm * (*func)(const time_t*))
{
#include <iostream>
#include <iomanip>
#include <cstring>
#include <sys/stat.h>
#include <pwd.h>
#include <grp.h>
#include <ctime>
using namespace std;