Skip to content

Instantly share code, notes, and snippets.

View mrklein's full-sized avatar

Alexey Matveichev mrklein

View GitHub Profile
#!/bin/bash
CHAIN=SELFCONTROL
IPTABLES=/sbin/iptables
IP_PATTERN='/^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$/p'
usage() {
echo "Usage: $0 <IP address or hostname>"
exit 1
}
" OpenFOAM/FreeFOAM
autocmd BufRead *.[CH] set expandtab shiftwidth=4 filetype=cpp
autocmd BufRead *.[CH] set cindent cinoptions=+s-2,(s,U1,is,g0,Ws,l1,t0 cinkeys=0{,0},0),:,!^F,o,O,e
;; for OpenFOAM
(c-add-style "OpenFOAM_HGW"
'(
(c-basic-offset . 4)
(c-tab-always-indent . t)
(indent-tabs-mode . nil)
(c-comment-only-line-offset . (0 . 0))
(c-indent-comments-syntactically-p . t)
(c-block-comments-indent-p nil)
(c-cleanup-list .
const fvPatchList& patches = mesh.boundary();
forAll(patches, patchi)
{
const fvPatch& curPatch = patches[patchi];
if (isType<wallFvPatch>(curPatch))
{
forAll(curPatch, facei)
{
label faceCelli = curPatch.faceCells()[facei];
@mrklein
mrklein / gist:5117819
Created March 8, 2013 16:41
Reconstructing case on the cluster
#PBS -l nodes=1
cd $PBS_O_WORKDIR
reconstructPar -case $PBS_O_WORKDIR > $PBS_O_WORKDIR/log.reconstructPar
@mrklein
mrklein / factorial.scm
Last active December 17, 2015 00:29
Two variant of factorial implementation with Bigloo Scheme. Bigloo specifics are in timing of calculations. Tested under Bigloo 4.0a.
(module fact)
(define *num-list* '(1 12 123 1234 12345 123456))
(define (factorial n)
(define (iter k acc)
(if (= k 1)
acc
(iter (- k 1) (* k acc))))
(iter n 1))
@mrklein
mrklein / gmp_test.c
Created May 5, 2013 14:52
Calculation of factorial and sum of number digits with GMP. Timing implemented for OS X.
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <mach/mach_time.h>
#include <gmp.h>
void factorial(mpz_t n, mpz_t res)
{
mpz_t unit, zero, cnt;
mpz_init_set_ui (unit, 1);
@mrklein
mrklein / stream-function-mpl.py
Last active December 31, 2015 16:09
streamFunction.patch
diff -ru streamFunction/Make/files streamFunctionV/Make/files
--- streamFunction/Make/files 2013-06-11 11:33:58.000000000 +0200
+++ streamFunctionV/Make/files 2013-12-17 15:15:36.255538814 +0100
@@ -1,3 +1,3 @@
streamFunction.C
-EXE = $(FOAM_APPBIN)/streamFunction
+EXE = $(FOAM_USER_APPBIN)/streamFunctionV
diff -ru streamFunction/streamFunction.C streamFunctionV/streamFunction.C
--- streamFunction/streamFunction.C 2013-06-11 11:33:58.000000000 +0200
#include <iostream>
#include <ctime>
#include <gmpxx.h>
typedef mpz_class Integer;
Integer N[] = {1, 12, 123, 1234, 12345, 123456};
Integer sum_digits(Integer n);
Integer factorial(Integer n);
alexey at daphne in tests$ clang++ gmp_test.cxx -lgmp -lgmpxx -std=c++11 -O3
alexey at daphne in tests$ ./a.out
2652733
Execution time: 8394.96 ms
alexey at daphne in tests$