Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃
wat

Ionel Cristian Mărieș ionelmc

🙃
wat
View GitHub Profile
@ionelmc
ionelmc / vbox-shutdown.py
Last active Sep 19, 2020
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:
View cheatsheet.rst
View hunter_profile_example.py
from time import time
from hunter import Action
from hunter import trace
class ProfileAction(Action):
def __init__(self):
self.timings = {}
def __call__(self, event):
View cod-blestemat.py
b = 1
def foo():
b = 2
class foo:
a = b
b = 3
return foo()
foo().a
@ionelmc
ionelmc / .gitignore
Last active Feb 12, 2020
A JSON parser benchmark. See README.rst for instructions.
View .gitignore
*.cbor
*.log
*.xml
*.yaml
*.json
*.msgpack
*.html
*.marshal
*.pickle
.tox
View gist:acbf546e00bab661f0b599475807db45
>>> delta = datetime.timedelta(days=200)
>>> tz = pytz.timezone('Europe/Bucharest')
>>> datetime_dt = datetime.datetime(2019, 1, 1, tzinfo=tz)
>>> print('datetime.datetime(2019, 1, 1, tzinfo=tz):', datetime_dt.isoformat())
datetime.datetime(2019, 1, 1, tzinfo=tz): 2019-01-01T00:00:00+01:44
>>> datetime_dt = tz.localize(datetime.datetime(2019, 1, 1))
>>> print('tz.localize(datetime.datetime(2019, 1, 1)):', datetime_dt.isoformat())
tz.localize(datetime.datetime(2019, 1, 1)): 2019-01-01T00:00:00+02:00
>>>
>>> print('datetime + delta:', (datetime_dt + delta).isoformat())
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)
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
You can’t perform that action at this time.