Skip to content

Instantly share code, notes, and snippets.

🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
Block or report user

Report or block ionelmc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cheatsheet.rst
View watch-sys-block-stat.sh
watch --difference=cummulative --interval=1 '(echo device read_IOs read_merges read_sectors read_ticks write_IOs write_merges write_sectors write_ticks in_flight io_ticks time_in_queue; for file in /sys/block/*/stat; do echo -n $file; cat $file; done) | column -t'
# OUTPUTS:
#device read_IOs read_merges read_sectors read_ticks write_IOs write_merges write_sectors write_ticks in_flight io_ticks time_in_queue
#/sys/block/dm-0/stat 116962 0 2212746 314096 7705653 0 150218536 609670232 0 644428 610921004
#/sys/block/dm-1/stat 116479 0 2208882 313324 7686986 0 150218536 609676068 0 644616 611418072
#/sys/block/dm-2/stat 302 0 2416 780 0 0 0 0 0 148 780
#/sys/block/sda/stat 91181 26273 2217246 74876 7314854 388030 150261802 16954364
@ionelmc
ionelmc / .gitignore
Last active Jun 16, 2019
Socat PPA (readline)
@ionelmc
ionelmc / vbox-shutdown.py
Last active May 29, 2019
VirtualBox automatic shutdown cleaner. Runs in the "notification icon area". When closed by windows it waits for VMs to shutdown (acpi) and if it doesn't work it tries to suspend the VMs.
View vbox-shutdown.py
import logging
import subprocess
import time
import sys
import win32con
import win32gui_struct
import os
try:
import winxpgui as win32gui
except ImportError:
@ionelmc
ionelmc / .gitignore
Last active Mar 17, 2019
A JSON parser benchmark. See README.rst for instructions.
View .gitignore
*.cbor
*.log
*.xml
*.yaml
*.json
*.msgpack
*.html
*.marshal
*.pickle
.tox
View signalfd-with-threads-sucks.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <pthread.h>
#include <sys/signalfd.h>
#include <sys/time.h>
#include <sys/types.h>
#define handle_error(msg) \
@ionelmc
ionelmc / conftest.py
Last active May 21, 2018
A more sophisticated celery fixture (logs + tree term)
View conftest.py
from __future__ import print_function
import subprocess
import sys
import time
import psutil
import pytest
@ionelmc
ionelmc / conftest.py
Created May 21, 2018
pytest-django support for subprocesses
View conftest.py
@pytest.fixture(scope='session')
def django_db_setup(request,
django_test_environment,
django_db_blocker,
django_db_use_migrations,
django_db_keepdb,
django_db_modify_db_settings):
import pytest_django.compat
def teardown_databases(db_cfg, verbosity, _teardown_databases=pytest_django.compat.teardown_databases):
View mongoquery2func.py
"""
Converts a dict containing a mongo query to a lambda. Doesn't support all the mongo
query $keywords, probably differs the result in subtle ways.
It only supports querying flat structures: dicts with no lists or other dicts in
them (aka subdocuments).
"""
from __future__ import print_function
import sys
import tempfile
@ionelmc
ionelmc / headerid.py
Last active Mar 17, 2018
Pelican plugin to add permalinks (headerid) to every section header when using reStructuredText. You can see it in action at http://blog.ionelmc.ro
View headerid.py
from pelican import readers
from pelican.readers import PelicanHTMLTranslator
from pelican import signals
from docutils import nodes
def register():
class HeaderIDPatchedPelicanHTMLTranslator(PelicanHTMLTranslator):
def depart_title(self, node):
close_tag = self.context[-1]
parent = node.parent
You can’t perform that action at this time.