Skip to content

Instantly share code, notes, and snippets.

View aterga's full-sized avatar
🎯
Focusing

Arshavir Ter-Gabrielyan aterga

🎯
Focusing
View GitHub Profile
@aterga
aterga / split_2d.cpp
Created September 18, 2012 13:50
Simple 2d array split method
void GameOfLife::split()
{
// Strategy:
n_x_nodes_ = n_nodes_;
n_y_nodes_ = 1;
int workload_per_node = 0;
int zero_node_workload = 0;
int n_actual_nodes = n_nodes_;
@aterga
aterga / gist:3805377
Created September 29, 2012 23:01
2-d array fabric
LIFE **alloc_mass_2d(int ncolumns, int nrows, LIFE init_val)
{
LIFE **array = (LIFE **) malloc(nrows * sizeof(LIFE *));
if (array == NULL)
{
fprintf(stderr, "out of memory\n");
return NULL;
}
for (int y = 0; y < nrows; y ++)
{
@aterga
aterga / gist:3877970
Created October 12, 2012 08:17
Representing naturals by sequence of prime factors
#include <vector>
typedef int num_t;
std::vector<num_t> *get_prime_factors(num_t num)
{
std::vector<num_t> *list = new std::vector<num_t>();
num_t start_num = num;
@aterga
aterga / caesar.pl
Created November 8, 2012 11:02
A simple unicode perl chipher decryption tool
#!/usr/bin/perl -w
use strict;
use warnings;
use utf8;
open FILE, "enc.txt" or die $!;
binmode FILE, ":utf8";
my $text = 0;
foreach my $line (<FILE>)
@aterga
aterga / find.pl
Created November 13, 2012 10:46
A useful Perl subroutine for finding matched lines in a text file. Handy for extraction of required content from a huge log files.
#!/usr/bin/perl -w
use strict;
use warnings;
if ($#ARGV != 2)
{
print " Usage: trace_extract_mlt_region.pl [TRACE_FILENAME] [DUMP_FILENAME] [STORE_OPERATION_INDEX]\n";
exit;
}
@aterga
aterga / univup.tcl
Created April 11, 2013 07:25
This is the bitbucket2masterhost.ru site updater called univup.exp!
#!/opt/local/bin/expect -f
################################
# Hello,
# this
# is
# the
# bitbucket2masterhost.ru
# site
# updater
# called
// class Node
field left: Ref
field right: Ref
field is_marked: Bool
predicate inv(node: Ref, graph: Set[Ref]) {
node != null
&& acc(node.left)
&& acc(node.right)
&& acc(node.is_marked)
@aterga
aterga / sv_boogie.bpl
Last active November 21, 2015 00:28
Verifying QuickSort in Boogie
const N: int;
axiom 1 < N;
var a: [int]int;
var perm: [int]int;
procedure __new_perm__() returns (perm: [int]int)
ensures perm_ok(perm);
ensures (forall k: int :: 0 <= k && k < N ==> perm[k] == k);
{
var n: int; n := 0;
@aterga
aterga / leg.sil
Created April 6, 2016 17:50
LSeg
field next: Ref
field value: Int
predicate lseg(this: Ref, end: Ref) {
acc(this.value, write) && acc(this.next, write) &&
(this.next != end ==> this.next != null && acc(lseg(this.next, end), write))
}
function get(this: Ref, i: Int, end: Ref): Int
requires acc(lseg(this, end), write)
@aterga
aterga / gist:473b050b73f93cf38240c3356bcf45a9
Created September 14, 2019 07:10
VMI Summer Retreat 2019 Master Class on Code Verification
field f: Ref
define CLOSED(nodes)
(forall n:Ref :: { n in nodes, n.f } n in nodes && n.f != null ==> n.f in nodes)
define STRUCT(nodes)
(forall n:Ref :: { n.f } n in nodes ==> acc(n.f)) &&
!(null in nodes) &&
CLOSED(nodes)