Skip to content

Instantly share code, notes, and snippets.

View a-square's full-sized avatar

Aleksei Averchenko a-square

View GitHub Profile
$ /usr/bin/time -l ./a.out test.txt
3000000 18000000 105000000 test.txt
0.17 real 0.14 user 0.03 sys
811008 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
207 page reclaims
0 page faults
0 swaps
@a-square
a-square / test.cpp
Created April 9, 2019 12:55
Binary value of (int TFoo::*)nullptr
#include <cstdint>
#include <cstring>
#include <iostream>
struct TFoo {
int Bar;
int Baz;
};
@a-square
a-square / jenkins-docker.sh
Last active February 26, 2017 12:22
From The Docker Book: using a docker container in Jenkins
IMAGE=$(sudo docker build . | tail -1 | awk '{ print $NF; }')
MNT="$WORKSPACE/.."
# patch MNT to point to the host directory
MNT=$(echo $MNT | sed -E 's|^.*jenkins_home|/Users/averchenko/Development/docker-book/jenkins/jenkins_home|')
CONTAINER=$(sudo docker run \
-d \
-v "$MNT":/opt/project \
$IMAGE \
#include <iostream>
class Foo {
public:
explicit Foo(int) {
throw "Wow!";
}
};
class Bar {
#!/usr/bin/env python3
def prepare():
values = list(range(5))
values.append(values)
return values
xs = prepare()
xs = xs + xs
#!/usr/bin/env python3
import functools
import inspect
import itertools
@functools.total_ordering
class Maybe:
"""Extension of the boolean logic.
#!/usr/bin/env python3
class Prop:
def __get__(self, instance, owner):
return 'foo'
class Foo:
foo = Prop()
@a-square
a-square / match.c
Last active December 3, 2016 01:27
/* gcc -O3 -std=c99 -o match match.c */
#include <unistd.h>
char* VALUES[] = { "false\n", "true\n" };
unsigned long SIZES[] = { 6, 5 };
int match(const char* restrict str, const char* restrict pattern) {
@a-square
a-square / strset.c
Created August 9, 2016 21:22
Matches a string against a string set, tells you which one it matched
#include <stdio.h>
#include <stdlib.h>
/*
* matches str to one of the strings in set (at most 32),
* returns the matched string or NULL
*/
char* strset(char** set, char* str) {
char* mset[32];
@a-square
a-square / run-oclint.sh
Created January 21, 2015 10:48
A modern CocoaPods-aware OCLint target script for Xcode
#
# parameters (including heuristic defaults)
#
if [ -z ${MY_SCHEME+x} ]
then
export MY_SCHEME=${PROJECT_NAME}
fi
if [ -z ${MY_WORKSPACE+x} ]