Skip to content

Instantly share code, notes, and snippets.

@Makman2
Makman2 / absolute_position_to_line_column.py
Created October 17, 2015 22:56
Converts absolute text position to line/column position
def _absolute_position_to_line_column(string, pos):
"""
Converts an absolute char-position to a line-column position.
:param string: The string where the position is associated to.
:param pos: The position to convert (starts from 0).
:returns: A pair with (line, column). Line and column start with 1.
"""
line = string.count("\n", 0, pos) + 1
column = string.rfind("\n", 0, pos)
from timeit import *
def conditional_check(a, b):
if a is None or b is None:
return 10
else:
return 24
def tuple_check(a, b):
@Makman2
Makman2 / ce3d2-example.cpp
Created January 10, 2016 01:02
First test program for CE3D2!
#include <CE3D2/render/TextSurface.h>
#include <iostream>
#include <string>
using TextSurface = CE3D2::Render::TextSurface;
void print_surface(TextSurface const& surf)
{
std::string border = "--";
for (TextSurface::size_type x = 0; x < surf.width(); x++)
from multiprocessing import Pool
if __name__ == "__main__":
# Initialize pool workers already
#
# Instantiate bears (params: the section and list of files that contains proxy objects serving the file as a string, presplitted lines and the file name, maybe other parameters)
#
# The file proxy objects contains lazy functions! So memory is only reserved on need
# for specific stuff. For that purposes maybe one can create a
# "MultiRepresentationObject" class that needs one specific "representation" of an
@Makman2
Makman2 / BearSetting.py
Created February 28, 2016 23:29
Prototype that shall replace get_metadata() more or less inside Bear
# TODO Don't think I need this, but maybe we switch to a simpler system instead
# TODO of grabbing function metadata. So idea is grab metadata but parse them
# TODO into these BearSetting's for easier use.
class BearSetting:
@enforce_signature
def __init__(self, name: str, typ: type, default=None):
if default is not None and type(default) is not typ:
raise ValueError("Default is not of given type.")
self._name = name
mak@localhost:~/dev/coala (master) +1 ~0 -0 $ py.test
Test session starts (platform: linux, Python 3.4.3, pytest 2.8.7, pytest-sugar 0.5.1)
rootdir: /home/mak/dev/coala, inifile: setup.cfg
plugins: timeout-1.0.0, sugar-0.5.1, xdist-1.14, doc-0.0.1, env-0.6.0, cov-2.2.1
docs/index.rst ⚫ 0%
docs/General_Dev_Info/git_tutorial_1.rst ⚫ 0% ▏
docs/Getting_Involved/Codestyle.rst ⚫ 1% ▏
docs/Getting_Involved/MAC_Hints.rst ⚫ 1% ▏
docs/Getting_Involved/Newcomers.rst ⚫ 1% ▏
@Makman2
Makman2 / dbus-error-11-3-2016-20-20.txt
Last active March 11, 2016 19:22
dbus-error-11-3-2016-20-20
mak@localhost:~/dev/coala (master) +1 ~0 -0 $ py.test
Test session starts (platform: linux, Python 3.4.3, pytest 2.8.7, pytest-sugar 0.5.1)
rootdir: /home/mak/dev/coala, inifile: setup.cfg
plugins: timeout-1.0.0, sugar-0.5.1, xdist-1.14, doc-0.0.1, env-0.6.0, cov-2.2.1
docs/index.rst ⚫ 0%
docs/General_Dev_Info/git_tutorial_1.rst ⚫ 0% ▏
docs/Getting_Involved/Codestyle.rst ⚫ 1% ▏
docs/Getting_Involved/MAC_Hints.rst ⚫ 1% ▏
docs/Getting_Involved/Newcomers.rst ⚫ 1% ▏
@Makman2
Makman2 / Application.scala
Created March 14, 2016 00:47
My first try to get jmonkeyengine running with scala
package coz
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
/** Sample 1 - how to get started with the most simple JME 3 application.
Afterwork improvements:
- Catch regex.compile error and rethrow as ValueError?
- Implement GlobalBear support
- More intelligent metadata-merge that is not so merge-order-sensitive
- regex-output-format: Implement even more checks:
- Use of capturing groups
- Unknown named capturing groups
- prerequisite_check_command: Remove and let the user override it
himself + provide helper utilities (advanced custom command check,
derivations for specific stuff (java module check etc.)
mak@hp-elitebook:~/dev/coala (master)$ git pull
Already up-to-date.
mak@hp-elitebook:~/dev/coala (master)$ sudo pip3 install coala coala-bears --pre --upgrade
Requirement already up-to-date: coala in /usr/lib/python3.4/site-packages
Requirement already up-to-date: coala-bears in /usr/lib/python3.4/site-packages
Requirement already up-to-date: setuptools>=19.2 in /usr/lib/python3.4/site-packages (from coala)
Requirement already up-to-date: validators~=0.10 in /usr/lib/python3.4/site-packages (from coala)
Requirement already up-to-date: libclang-py3==0.2 in /usr/lib/python3.4/site-packages (from coala)
Requirement already up-to-date: PyPrint~=0.2.3 in /usr/lib/python3.4/site-packages (from coala)
Requirement already up-to-date: appdirs~=1.4.0 in /usr/lib/python3.4/site-packages (from coala)