Skip to content

Instantly share code, notes, and snippets.

dobrokot

Block or report user

Report or block dobrokot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dobrokot
dobrokot / namedtuple_memory_test.py
Last active Aug 29, 2015
python tuple/named type memory test
View namedtuple_memory_test.py
from collections import namedtuple
import numpy
Point = namedtuple('Point', ['x', 'y'])
class Point2:
def __init__(self, x, y):
self.x = x
self.y = y
@dobrokot
dobrokot / alloc-mem-test.cpp
Created Dec 8, 2014
allocate memory to test system behavior
View alloc-mem-test.cpp
#include <stdio.h>
#include <stdlib.h>
// malloc some number of gigabytes, to test impact on system
// g++ -O3 alloc-mem-test.cpp && ./a.out
size_t WIDTH = 75;
int progress_bar(size_t i, size_t size) {
return i * WIDTH / size;
}
@dobrokot
dobrokot / download-build-clang.sh
Last active Aug 29, 2015
download and build clang
View download-build-clang.sh
set -eu
#скачиваю и распаковываю архивы из интернета
curl -sS http://llvm.org/releases/3.5.0/llvm-3.5.0.src.tar.xz | tar -xJf - &
curl -sS http://llvm.org/releases/3.5.0/cfe-3.5.0.src.tar.xz | tar -xJf - &
curl -sS http://llvm.org/releases/3.5.0/compiler-rt-3.5.0.src.tar.xz | tar -xJf - &
curl -sS http://llvm.org/releases/3.5.0/clang-tools-extra-3.5.0.src.tar.xz | tar -xJf - &
wait #жду, пока всё скачается
#mv в существующую папку создаёт лишний уровень иерархии, поэтому проверка на несуществование
@dobrokot
dobrokot / glass_water_avva.py
Last active Aug 29, 2015
avva glass water problem
View glass_water_avva.py
# -*- encoding: UTF-8 -*-
# http://avva.livejournal.com/2827068.html
# run as:
# ( echo шир. узк. ; python glass_water_avva.py | tac ) | column -t
# v1 - широкий стакан
# v2 - узкий стакан
from fractions import Fraction
@dobrokot
dobrokot / filename_punctuation_strip.py
Created Nov 3, 2014
strip punctiation from file names
View filename_punctuation_strip.py
import os, re
fs = []
for x in os.listdir('.'):
if x.endswith('.mp4'):
fs.append((os.path.getsize(x), x))
fs2 = []
View uatrats.diff
#include "uatraits/details/branch.hpp"
#include "uatraits/details/definition.hpp"
-#include "uatraits/details/hash_utils.hpp"
#include "uatraits/details/regex_definition.hpp"
#include "uatraits/details/static_definition.hpp"
#include "uatraits/details/string_definition.hpp"
@@ -181,7 +180,7 @@
header = header.substr(0, header.length() - sizeof (to_strip) + 1);
}
View check_all.sh
mkdir src_dir
mkdir exec_dir
python generate_variants.py
ls src_dir | xargs -P 100 -IF gcc src_dir/F -o exec_dir/F.x 2>/dev/null
find exec_dir/ | xargs -n 1 -P 1000 ./check_prog.sh
View find_unused_vars.sh
(
find . -name '*.cpp' -or -name '*.h' | xargs grep -E '^ *[a-zA-Z0-9< >,:_]+ +[a-zA-Z0-9_]+;$' -o -h | grep '<' | grep '>' ;
find . -name '*.cpp' -or -name '*.h' | xargs grep -E '^ *[a-zA-Z0-9_]+ +[a-zA-Z0-9_]+;$' -o -h
) | awk '{print $2}' | sort -u | tr -d ';' > ../names.txt
find . -name '*.cpp' -or -name '*.h' | xargs fgrep --word-regexp -f ../names.txt -oh | sort | uniq -c | awk '$1 <= 2'
@dobrokot
dobrokot / select_print.cpp
Last active Aug 29, 2015
select different print for containers and non-containers
View select_print.cpp
//compile with g++ -std=c++11 select_print.cpp
#include <vector>
#include <iostream>
#include <string>
namespace detail {
struct FromAny {
template <class T> FromAny(const T&) {}
@dobrokot
dobrokot / lambdaman.gcc
Created Aug 4, 2014
icfp 2014 lambda-man asm and code
View lambdaman.gcc
LD 0 0 ; 00
LD 0 1 ; 01
LDF 5 ; 02
LDC 0 ; 03
TSEL 1824 1824 ; 04
LDC 1 ; 05
LDC 2 ; 06
LDC 3 ; 07
LDC 0 ; 08
CONS ; 09
You can’t perform that action at this time.