Skip to content

Instantly share code, notes, and snippets.

View vdudouyt's full-sized avatar

Valentin Dudouyt vdudouyt

  • Novosibirsk, Russia
View GitHub Profile
# Synopsis:
# LSUsbParser = create_parser('LSUsbResult', 'ID (\w+):(\w+) (.*)',
# LSUsbParser.parse(subprocess.check_output("lsusb"))
import functools, re, collections
def match_against_field_names(regex, field_names, string):
matched = re.search(regex, string)
if matched is not None:
return dict(zip(field_names, matched.groups()))
@vdudouyt
vdudouyt / gist:7982559
Last active December 31, 2015 11:49
Programmatically add cronjob with Shell
add_cronjob() {
if [[ `crontab -l|grep "$2"` ]]; then
echo "Cronjob already exists, do not adding"
return
fi
(crontab -l; echo "$1" "$2")|crontab -
}
# add_cronjob '*/1 * * * *' 'cd /var/www/cgi-bin/ && ./run.sh 2>&1 >/dev/null'
@vdudouyt
vdudouyt / gist:7784630
Created December 4, 2013 09:16
Group a Perl array
sub group
{
my ($group_size, @array) = @_;
my ($i, @ret);
push @{$ret[$i++/$group_size]}, $_ for @array;
return @ret;
}
@vdudouyt
vdudouyt / ckjv.bash
Created October 11, 2013 02:15 — forked from barce/ckjv.bash
#!/bin/bash
grep '[\x{4E00}-\x{9FBF}|\x{3040}-\x{309F}|\x{30A0}-\x{30FF}]' test.txt
From 7341a316c38a61cc745ce04e618916677007883b Mon Sep 17 00:00:00 2001
From: Timothy Brom <thb@timbrom.com>
Date: Wed, 29 Feb 2012 11:29:55 -0500
Subject: [PATCH] Fixed error about strexh and strexb using the same register
---
example/libs_stm/inc/core_support/core_cm3.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/example/libs_stm/inc/core_support/core_cm3.c b/example/libs_stm/inc/core_support/core_cm3.c
@vdudouyt
vdudouyt / gist:6850206
Created October 6, 2013 06:17
Count unique kanji with Bash
grep -Po "[\xe4-\xe9][\x80-\xbf][\x80-\xbf]" wordsjp wordsjp1 wordsjp2|sort|uniq|wc -l
@vdudouyt
vdudouyt / gist:6238113
Last active March 21, 2021 18:29
A minimal working FUSE filesystem
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fuse.h>
// Synopsis:
// gcc fuse_minimal.c -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 `pkg-config --cflags --libs fuse` -o fuse_minimal
// ./fuse_minimal -f /mnt/fuse_minimal
int fuse_getattr(const char *path, struct stat *statbuf);

Section

aaa

Subsection

  • item1
  • item2