Skip to content

Instantly share code, notes, and snippets.

View griwes's full-sized avatar

Michał Dominiak griwes

View GitHub Profile
#include <string>
#include <memory>
#include <type_traits>
#include <iostream>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <thread>
#include <unordered_map>
// functional:
return boost::join(map(_name.id_expression_value, [](auto && elem) { return elem.string; }), ".");
// C++:
std::vector<std::string> tmp;
tmp.reserve(_name.id_expression_value.size());
std::transform(_name.id_expression_value.begin(), _name.id_expression_value.end(), std::back_inserter(tmp), [](auto && elem) { return elem.string; });
return boost::join(tmp, ".");
@griwes
griwes / gist:b85a79dd91698aa47f3c
Last active August 29, 2015 14:21
Vapor language - `mutable` vs `const` vs immutable

C++ has three categories of constness - the default one, so "mutable", mutable which walks around const, and const, which stops modification, but not of mutable members. This is obviously kind of backwards, and that's because the default is not immutable.

Rust has two categories of constness - the default one, so immutable, and mut, which marks a declaration as mutable. This is also obviously wrong, because you cannot have a "this might be mutated, but you cannot do that" kind of a, say, argument to a function. One could say this is justified, because it makes creating data races harder, but I'd like to argue that that is not true in any aspect, at least in the "mutable and non-unique means an actor" model of Vapor.

Vapor has three categories of reference constness:

  • the default one, so immutable; the default kind of a reference is called "a reference to an immutable object"
  • mutable, which allows modification to an object. You can have multiple references to a mutable object, but once you

Keybase proof

I hereby claim:

  • I am griwes on github.
  • I am griwes (https://keybase.io/griwes) on keybase.
  • I have a public key whose fingerprint is C218 EB21 1690 C4DC E124 2E4D D041 9DBA 618B 12D5

To claim this, I am signing this object:

griwes@Griwes-Linux ~/tests $ clang++ main.cpp -std=c++11 -stdlib=libc++ -lc++abi
griwes@Griwes-Linux ~/tests $ ./a.out
Attempts: 1000000000
Successes: 499975732
S/A: 0.499976
Attempts with change: 499990979
Successes with change: 333311610
S/A (changed): 0.666635
Attempts without change: 500009021
Successes without change: 166664122
@griwes
griwes / gist:5736853
Last active December 18, 2015 05:59
Some concepts for Reaver Shell. Keep in mind that this is just a text-only sketch; many of the features that are planned for RSh will not be available in text mode - I'm talking, for example, about clickable buttons for directories after `list`. The exact behavior is not really decided yet; I was thinking like, single click == `enter <directory>…
ReaverShell 0.3.1, running on ReaverOS 0.1.1 alpha.
Hello there, Griwes!
griwes@Griwes-Reaver 11:19:10 PM /user/griwes $ list
desktop directory, 12.00 KiB in 12 elements
documents directory, 14.02 MiB in 33 elements
downloads directory, 55.42 GiB in 124 elements
music directory, 120.4 GiB in 2043 elements
griwes@Griwes-Reaver 11:20:55 PM /user/griwes $ hello, rvcs
griwes@Griwes-Reaver 11:21:40 PM /user/griwes > rvcs $ status
No repository initialized in directory /user/griwes.
"Wyznanie kalifa, czyli o mocy baśni"
sł. i muz. Jacek Kaczmarski
Słowem drobnego wyjaśnienia - znak '+' przed akordem oznacza, że z akordu poprzedniego na oznaczony akord
(a więc w miejscu, gdzie znajduje się '+') znajduje się specjalne przejście między akordami, zależne rzecz
jasna od samych akordów (a też i od miejsca w tekście). Oznaczenia te bazują na wykonaniu, które znajduje
się na albumie "Dwie skały"; tam też (tj. w nagraniu) polecam poszukiwać dodatkowych informacji na temat
tychże przejść.
@griwes
griwes / osdev.md
Last active December 23, 2015 11:06
#osdev.txt

klange: This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.

drake1: as long as the lock is read and modified by atomic operations

Kazinsal: because if you drag on a discussion about how to store secondary files for a fucking bootloader for more than ten minutes, you should be forced to use yaml as a filesystem as punishment

@griwes
griwes / cmake_hacks.md
Created June 29, 2016 12:25
stupid cmake hacks
On 03/10/2011 12:25 AM, Andreas Pakulat wrote:
> On 09.03.11 21:36:25, Ankur Handa wrote:
>> I'm using find_library to find a library in a given directory but it has
>> many different versions of this library listed as libcxcore.so,
>> libcxcore.so.2.1 and libcxcore.so.2.1.0  I wrote a very simple cmake file
>>
>> cmake_minimum_required(VERSION 2.8)
>>
"Jak się nie stoczyć"
sł. i muz. Paweł Wójcik
I znowu siedzimy Tomaszu przy stole e D
Nie sięgaj po portfel bo dziś moja kolej G D
Lubimy ten gwar, muzyczka nam gra e D
Wódeczka do dna G D
Siedzimy przy stole, coś mówisz o żonie