Skip to content

Instantly share code, notes, and snippets.

View vdudouyt's full-sized avatar

Valentin Dudouyt vdudouyt

  • Novosibirsk, Russia
View GitHub Profile

Section

aaa

Subsection

  • item1
  • item2
@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);
@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
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 / 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
@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 / 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'
# 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()))
#!/usr/bin/perl
# Generates PyUSB equivalent from the capture log
#
# Synopsis:
# ./gen_pyusb.pl <test_unit_ready.cap --asserts
# dev.write(2, hex_to_list('55534243707ec2810000000000000600000000000000000000000000000000'))
# assert(list(dev.read(0x81, 26)) == hex_to_list('55534253707ec2810000000000'))
#
# .vimrc:
@vdudouyt
vdudouyt / bashrc
Created December 26, 2013 08:08
GVimDiff helpers
# Synopsis:
# set_base_dir ../branch1/cgi-bin/
# merge index.cgi
# merge ../style.css
alias merge=merge_changes
set_base_dir() {
export BASE_DIR=$(readlink -f $1)
}
merge_changes() {