Skip to content

Instantly share code, notes, and snippets.

View vstakhov's full-sized avatar

Vsevolod Stakhov vstakhov

  • Cambridge, UK
  • 14:42 (UTC +01:00)
View GitHub Profile
@vstakhov
vstakhov / pre-commit.sh
Created January 28, 2016 15:20
Pre-commit hook for git to enable whitespaces sanity checks and fixes
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
@vstakhov
vstakhov / re_test.cc
Last active December 11, 2015 13:21
hyperscan/pcre benchmark
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <stdexcept>
#include <algorithm>
#include <set>
#include "pcre.h"
#include "hs.h"
#include <time.h>
diff --git a/app/extensions/blake2b/blake2b_avx2-64.inc b/app/extensions/blake2b/blake2b_avx2-64.inc
index 055131a..4fc2a48 100644
--- a/app/extensions/blake2b/blake2b_avx2-64.inc
+++ b/app/extensions/blake2b/blake2b_avx2-64.inc
@@ -93,7 +93,7 @@ vmovdqa %ymm0, %ymm2
vmovdqa %ymm1, %ymm3
vmovq %r8, %xmm5
adcq $0, %r9
-movl $blake2b_sigma, %eax
+movl blake2b_sigma(%rip), %eax
@vstakhov
vstakhov / rmilter.md
Created September 8, 2015 14:38
rmilter plans

Plans for rmilter

What's wrong

Rmilter had been created some years before rspamd development started. Unfortunately, it wasn't actively developed for many years so far. It has several design flaws, it uses archaic configuration system, it uses threads, it contains a lot of duplicated functions with rspamd and, finally, it has a lot of code shared with rspamd (but it's not always up-to-date however). I hasn't found anybody willing to support this code as a separate project, so I think it's a good point to stop and think of what to do afterwards.

What's proposed to do

After some thinking I've decided to reorganize rmilter project and to integrate it to the rspamd meta-project.

rspamd_config.R_EMPTY_IMAGE = {
callback = function(task)
local tp = task:get_text_parts() -- get text parts in a message
for _,p in ipairs(tp) do -- iterate over text parts array using `ipairs`
if p:is_html() then -- if the current part is html part
local hc = p:get_html() -- we get HTML context
local len = p:get_length() -- and part's length
if len < 50 then -- if we have a part that has less than 50 bytes of text
@vstakhov
vstakhov / nlines.c
Last active December 17, 2015 00:18
Measure performance of different algorithms to match lines count in a text.
#include <sys/time.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#ifdef __SSE__
#include <immintrin.h>
@vstakhov
vstakhov / rspamd.com.sh
Created April 18, 2015 18:49
git post-receive hook
#!/bin/sh
HOME=/home/cebka
GIT_REPO=$HOME/rspamd.com.git
TMP_GIT_CLONE=/tmp/rspamd.com
PUBLIC_WWW=$HOME/rspamd.com
RSPAMD_REPO=$HOME/rspamd.git
TMP_RSPAMD=/tmp/rspamd
SED_SCRIPT="sed -e 's|^~~~\([a-zA-Z].*\)$|{% highlight \1 %}|' -e 's|^~~~$|{% endhighlight %}|' -e 's/.md)/.html)/g'"
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <xfs/xfs.h>
int
main(void)
{
Index: af_inet6.c
===================================================================
--- af_inet6.c (revision 277757)
+++ af_inet6.c (working copy)
@@ -167,6 +167,34 @@
}
static void
+in6_print_scope(uint8_t *a)
+{
Index: ifconfig.c
===================================================================
--- ifconfig.c (revision 277757)
+++ ifconfig.c (working copy)
@@ -141,6 +141,100 @@
exit(1);
}
+static void
+calcorders(struct ifaddrs *ifa, int *orders, int cnt)