Skip to content

Instantly share code, notes, and snippets.

View Niakr1s's full-sized avatar
Coding...

Niakr1s

Coding...
View GitHub Profile
@Niakr1s
Niakr1s / PyQT_PyCharm_traceback_fix.py
Last active April 15, 2018 11:04
Pycharm to show PyQT exceptions
from PyQt5 import QtCore
import traceback, sys
# https://stackoverflow.com/questions/44447674/traceback-missing-when-exception-encountered-in-pyqt5-code-in-eclipsepydev
if QtCore.QT_VERSION >= 0x50501:
def excepthook(type_, value, traceback_):
traceback.print_exception(type_, value, traceback_)
QtCore.qFatal('')
sys.excepthook = excepthook
@Niakr1s
Niakr1s / lib.rs
Created July 19, 2018 17:11
RustBook 2nd edition 17.3 (2nd part implementation)
pub enum Content {
Post(String),
DraftPost(String),
PendingReviewPost(String),
}
pub struct Post {
approved: i32,
content: Content,
}
@Niakr1s
Niakr1s / rosreestr.go
Created October 25, 2018 11:25
xml parsing example
package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
)
type CadastralBlock struct {
@Niakr1s
Niakr1s / Makefile
Last active March 16, 2019 08:06
simple makefile
CC = g++
CFLAGS = -Wall
LDFLAGS =
SRC_PATH = src/
MAIN_OBJ = main.o # to filter out it from test objs
SRCS = $(wildcard $(SRC_PATH)*.cpp) # get all .cpp in src dir
# for tests
TEST_CFLAGS = $(CFLAGS) -Id:/libs/boost_1_69_0/stage/include/boost-1_69
TEST_LDFLAGS = $(LDFLAGS) -Ld:/libs/boost_1_69_0/stage/lib -lboost_unit_test_framework-mgw82-mt-s-x32-1_69
TEST_PATH = tests/
@Niakr1s
Niakr1s / TreeNode.cpp
Last active March 11, 2019 16:36
Simple TreeNode list
#include "TreeNode.h"
int TreeNode::num = 0;
TreeNode::TreeNode(const string s,
TreeNode *l, TreeNode *r) : value(s), count(num++), left(l), right(r)
{
if (l)
l->right = this;
};
@Niakr1s
Niakr1s / StrVec.cpp
Last active March 12, 2019 07:18
simple StrVec impl
#include "StrVec.h"
StrVec::StrVec(const string &s) : StrVec::StrVec()
{
push_back(s);
}
StrVec::~StrVec() { free(); };
StrVec::StrVec(const StrVec &rhs) : elements(rhs.elements), first_free(rhs.first_free), cap(rhs.cap)
{
@Niakr1s
Niakr1s / .gdbinit
Last active March 14, 2019 10:05
enable pretty-printers gdb
python
import sys
sys.path.insert(0, "d:\\MinGW\\share\\gcc-8.2.0\\python")
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
@Niakr1s
Niakr1s / boost_build.bat
Last active March 16, 2019 08:27
my boost build config
@echo off
echo Make sure you had run "bootstrap.bat gcc" before
echo ________________________________________________
b2 address-model=32 architecture=x86 --with-test threading=multi -j 8 install
echo ______________________________________________
echo You got your built Boost in "c:/Boost"! Enjoy!
@Niakr1s
Niakr1s / CMakeLists.txt
Created March 16, 2019 19:25
simple CMakeLists
cmake_minimum_required(VERSION 3.0.0)
project(main VERSION 0.1.0)
enable_testing()
file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp")
add_executable(main ${SOURCES})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
@Niakr1s
Niakr1s / cmake_windows_icon.txt
Created November 23, 2019 19:55
How to add icon to cmake app in windows
1. Put app.ico in directory.
2. Create app.rc in same directory with one line:
IDI_ICON1 ICON DISCARDABLE "app.ico"
3. Run command (Warning: it's app.o, not app.res, how it is mentioned in other manuals!)
windres app.rc -o app.o
4. add_executable(app
...