Skip to content

Instantly share code, notes, and snippets.

sed -i 's/\s\+$//' `find CE3D -name "*.cpp";find CE3D -name "*.h"`
@Makman2
Makman2 / regex_proto.py
Last active August 29, 2015 14:16
regex_proto.py
import re
# Just a forwarding method for re.split(), that splits unescaped.
# NOTE: If max_split it a number above 0, unescaped_split() appends the
# remaining unprocessed string to the result list!
def unescaped_split(pattern,
string,
max_split = 0,
remove_empty_matches = False):
match = re.split(pattern, string, max_split)
@Makman2
Makman2 / process-interrupter.py
Created August 2, 2015 22:10
How to interrupt a process correctly in windows so catch and finally get executed.
from multiprocessing import Process, Queue
from time import sleep
import ctypes
# WINDOWS ONLY!!!
def interrupt_process(pid):
CTRL_C_EVENT = 0x0
ctypes.windll.kernel32.GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid)
# DON'T USE THIS!!! THIS WON'T WORK AND GENERATES A COMPLETELY DIFFERENT
from multiprocessing import Process, Queue
from time import sleep
import os
import ctypes
import sys
import platform
# WINDOWS ONLY!!!
@Makman2
Makman2 / test_each.sh
Last active July 25, 2017 20:39
Allows to invoke a test-step for each commit made.
#!/bin/bash
set -e
# The test invocation.
function test_step {
echo "Updating setup.cfg..."
sed -i -e "s/ --cov//g" setup.cfg
py.test -k core
git reset --hard
}
@Makman2
Makman2 / ctype_async_raise.py
Last active August 31, 2015 00:55 — forked from liuw/ctype_async_raise.py
Nasty hack to raise exception for other threads
#!/usr/bin/env python
# liuw
# Nasty hack to raise exception for other threads
import ctypes # Calm down, this has become standard library since 2.5
import threading
import time
NULL = 0
mak@localhost:~/dev/coala (sils/printcol) +1 ~0 -0 $ ./run_tests.py
1/81 | ApplyPatchActionTest
2/81 | BearRunningTest
3/81 | BearTest
4/81 | BuildDbusServiceTest
5/81 | BuildManPageTest
6/81 | ClangASTPrintBearTest
7/81 | ClangCloneDetectionBearTest
8/81 | ClangCountingConditionsTest
9/81 | ClangCountVectorCreatorTest
@Makman2
Makman2 / satellizer-oauth-fail
Created October 5, 2015 15:38
satellizer-oauth-fail
^Cmak@localhost:~/dev/gitmate-satellizer (master)$ ./runserver.sh
* Running on http://127.0.0.1:3000/
* Restarting with reloader
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET /stylesheets/angular-toastr.css HTTP/1.1" 304 -
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET /stylesheets/styles.css HTTP/1.1" 304 -
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET /vendor/angular.js HTTP/1.1" 304 -
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET /vendor/angular-animate.js HTTP/1.1" 304 -
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET /vendor/angular-messages.js HTTP/1.1" 304 -
127.0.0.1 - - [05/Oct/2015 17:36:48] "GET /vendor/angular-resource.js HTTP/1.1" 304 -
@Makman2
Makman2 / InterruptableThread.py
Last active October 9, 2015 21:53
WIP-Prototype for InterruptableThread
# Prototype for an InterruptableProcess.
# 8.10.2015 --> Makman2
import ctypes
import multiprocessing
import threading
def _wait_for_single(*events):
"""
Waits for at least one event being set.
@Makman2
Makman2 / InterruptableProcessTest.py
Created October 9, 2015 21:54
Test for InterruptableProcess
import unittest
from multiprocessing import Event
from InterruptableProcess import InterruptableProcess
class InterruptableProcessTest(unittest.TestCase):
def test_normal_run(self):
def worker(e1, e2, e3):
e1.wait()