Skip to content

Instantly share code, notes, and snippets.

@karliss
karliss / merge_lists.cpp
Last active November 29, 2017 08:21
merge lists
//https://news.ycombinator.com/item?id=15804795#15804931
#include <algorithm>
#include <vector>
using intVectors = std::vector<std::vector<int> >;
std::vector<int> mergeLists(intVectors lists)
{
if (lists.empty()) return {};
while (lists.size() > 1) {
intVectors newLists;
from heapq import merge
def merge_lists(lists):
if not lists:
return []
while len(lists) > 1:
a=[]
new_lists = []
if len(lists) % 2:
new_lists.append(lists.pop())
"set t_Co=256
set expandtab
set shiftwidth=4
set tabstop=4
autocmd FileType python set tabstop=2|set shiftwidth=2|set expandtab
autocmd FileType make set noexpandtab
set number
set list
set listchars=eol:$,tab:>-,trail:~
syntax on
@karliss
karliss / highdpi.md
Last active July 20, 2019 09:36
High dpi support notes

High dpi support notes

Compatiblity modes

TODO have a good understanding of backwards compatiblity modess supported by QT and various OS

OS specific highdpi support optin

Both Windows and MacOS require program to explicitly optin for full high dpi support. See QT documentation for that. Not sure how much of that QT do automatically and what needs to be done manually by us.

Thread #1
1 __asan::Allocator::Allocate asan_allocator.cc 524 0x7ffff755e86f
2 __asan::asan_malloc asan_allocator.cc 874 0x7ffff755abdb
3 __interceptor_malloc asan_malloc_linux.cc 145 0x7ffff7643baa
4 r_str_escape_utf8_for_json str.c 1446 0x7ffff6290314
5 pj_s
@karliss
karliss / generated.hx
Created February 21, 2020 16:48
Haxeui generated temp variables
// Old version
var c0 = new haxe.ui.containers.VBox();
c0.set_percentWidth(100.);
c0.set_percentHeight(100.);
c0.set_styleString("padding: 5px;");
var c1 = new haxe.ui.containers.menus.MenuBar();
c1.set_id("mainMenu");
c1.set_percentWidth(100.);
var c2 = new haxe.ui.containers.menus.Menu();
c2.set_text("File");
diff --git a/radare2/libr/util/strbuf.c b/radare2/libr/util/strbuf.c
index 01bde8c37..7791412ba 100644
--- a/radare2/libr/util/strbuf.c
+++ b/radare2/libr/util/strbuf.c
@@ -213,6 +213,11 @@ R_API bool r_strbuf_append_n(RStrBuf *sb, const char *s, int l) {
R_FREE (sb->ptr);
} else {
int newlen = sb->len + l + 128;
+ if (newlen < INT_MAX / 2) {
+ newlen *= 2;
@karliss
karliss / async cutter.md
Last active April 9, 2020 12:59
Async cutter notes

Assumptions

It is unsafe to perform any kind of r2 operations in parallel. This means thats that all access to r2 api must be controlled by a lock (this is already being done). Any kind of access to r2 API can be blocking for unknown amount of time. No r2 API can be done in GUI thread.

Proposed architecture version 2

  • run all interaction with r2 through r2_tasks except the task launching and some setup code
  • required r2 task changes
    • runing c function as task
  • threadpool
@karliss
karliss / gist:3b3e186a801bedcb95b9a692dc888173
Created April 7, 2020 14:42
cutter doc sphinx 3 backtrace
# Sphinx version: 3.0.0
# Python version: 3.8.2 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.11.1
# Last messages:
# loading pickled environment...
# failed
# failed: build environment version not current
# building [mo]: targets for 0 po files that are out of date
# building [html]: targets for 330 source files that are out of date
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.