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 / tzset_slow_test.cpp
Created Feb 27, 2014
Slow tzset + localtime
View tzset_slow_test.cpp
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <string>
std::string tzs[] = {
"Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", "Africa/Asmera", "Africa/Bamako", "Africa/Bangui", "Africa/Banjul", "Africa/Bissau", "Africa/Brazzaville", "Africa/Bujumbura", "Africa/Cairo", "Africa/Casablanca", "Africa/Conakry", "Africa/Dakar", "Africa/Dar_es_Salaam", "Africa/Djibouti", "Africa/Douala", "Africa/El_Aaiun", "Africa/Freetown", "Africa/Gaborone", "Africa/Harare", "Africa/Johannesburg", "Africa/Kampala", "Africa/Khartoum", "Africa/Kigali", "Africa/Kinshasa", "Africa/Lagos", "Africa/Libreville", "Africa/Lome", "Africa/Lusaka", "Africa/Malabo", "Africa/Maputo", "Africa/Maseru", "Africa/Mbabane", "Africa/Mogadishu", "Africa/Monrovia", "Africa/Nairobi", "Africa/Ndjamena", "Africa/Niamey", "Africa/Nouakchott", "Africa/Porto-Novo", "Africa/Sao_Tome", "Africa/Tripoli", "Africa/Tunis", "Africa/Windhoek", "America/Anchorage", "America/Anguilla", "America/An
@dobrokot
dobrokot / sshcp.sh
Created Mar 13, 2014
copy directory fron host to (local or other) host
View sshcp.sh
#!/usr/bin/env bash
set -eu
if [ "." == "$2" ]; then
CMD="tar -xvzf -";
else
case "$2" in
"dev") H="kotic.dev.zla.net" ;;
"gen") H="kotic-gen.proto.zla.net" ;;
*) H="$2" ;;
@dobrokot
dobrokot / dobro_backup.py
Last active Aug 29, 2015
dobro_backup.py - fast incremental backup
View dobro_backup.py
#!/usr/bin/env python
USAGE = '''
Incremental backup program
Usage: python "prog_name" destination_dir path1/source1 ... pathN/sourceN'
Copied result will be in the destination_dir/DATE_TIME/source1 ... destination_dir/DATE_TIME/sourceN'
Also there will be created files pathN/sourceN/hash_dir_info.txt (write access to source is needed now)'
When backup is complete, destination_dir/DATE_TIME/backup.complete is created, with timestamp info.
View gist:4eb2229599b34c8d55e9
докажите что в последовательности [2/sqrt(2)], [2^2/sqrt(2)], ... [2^n/sqrt(2)] .... , где [] - операция взятия целой части бесконечно много нечетных чисел
---------------------------------------------------
Для определёности, две последовательности (вторая - целые части первой):
An = (2^n)/sqrt(2)
Bn = [An] = [ (2^n)/sqrt(2) ]
Метод решения: посмотрел на картинке, что происходит с числами последовательности An "по модулю 2" в промежутке [0..2), там сразу видно: если число нечётное, то каждый раз удваивается расстояние от правой границы отрезка [0..2)
---------------------------------------------------
Формальные логические шаги:
Если четных Bn - конечное число, то бесконечно много нечетных Bn.
View gccg.py
import sys, re
# convert lispy-like language to 'lambda-man' ICFP2014 assembler.
# output is JavaScript, loaded in browser
def parse(s, i):
node = []
while 1:
while i < len(s) and (s[i] == ' ' or s[i] == '\n' or s[i] == '\r' or s[i] == '\t'):
i = i+1
@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
@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&) {}
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'
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 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);
}
You can’t perform that action at this time.