Skip to content

Instantly share code, notes, and snippets.

@nabijaczleweli
nabijaczleweli / .clang-format
Created July 1, 2015 10:30
nabijaczleweli's one true code style
---
Language : Cpp
BasedOnStyle : LLVM
AlignAfterOpenBracket : true
AlignEscapedNewlinesLeft : true
AlignConsecutiveAssignments : true
AllowShortFunctionsOnASingleLine : Empty
AlwaysBreakTemplateDeclarations : true
ColumnLimit : 160
ConstructorInitializerIndentWidth : 6
@nabijaczleweli
nabijaczleweli / Makefile
Last active August 29, 2015 14:24
Indoctrinating @Nooble part 1
# I normally put this in a separate file, but v0v
ifeq "$(OS)" "Windows_NT"
devnull := nul
DLL := .dll
MKDIR := busybox mkdir
PIC :=
PREDLL =
FIND = busybox find
else
devnull := /dev/null
@nabijaczleweli
nabijaczleweli / asdf.cpp
Created July 8, 2015 16:58
Why LINUX-based OSs are bad
void f00() {
throw 'f';
}
if(bugfree::Context * curctx = bugfree::Context::GetCurrentContext())
curctx->GoToShit();
@nabijaczleweli
nabijaczleweli / asdf.cpp
Created July 25, 2015 16:59
Find first unlocked mutex
#include <mutex>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
vector<mutex> mutexes(20);
for(int i = 0; i < 10; ++i)
@nabijaczleweli
nabijaczleweli / gaemsaev
Created July 27, 2015 22:18
Default saev
16 16
{x=4,y=13} =
{x=5,y=13} =
{x=6,y=13} =
{x=7,y=13} =
{x=8,y=13} =
{x=10,y=14} =
{x=11,y=14} =
@nabijaczleweli
nabijaczleweli / keybase.md
Last active August 29, 2015 14:28
My Keybase proof

Keybase proof

I hereby claim:

  • I am nabijaczleweli on github.
  • I am nabijaczleweli (https://keybase.io/nabijaczleweli) on keybase.
  • I have a public key whose fingerprint is 7D69 474E 8402 8C5C C0C4 4163 BCFD 0B01 8D26 58F1

To claim this, I am signing this object:

@nabijaczleweli
nabijaczleweli / line.cpp
Created September 14, 2015 16:30
static-const-nontrivial-init
void strip_line(string & line) {
static const vector<regex> regices = [&]() {
vector<regex> temp(3);
for(const auto reg : {"#.*", " +$", "^ +"}) // comment, start-of-line space, end-of-line space
temp.emplace_back(reg, regex_constants::optimize);
return temp;
}(); // <-- any better way of doing this?
for(const auto & rgx : regices)
line = regex_replace(line, rgx, "");
@nabijaczleweli
nabijaczleweli / sysprops.cpp
Created September 16, 2015 21:30
10/10 error handling
if(const auto sys = envvar_or({"OS"}, nullptr))
return sys;
throw runtime_error("the world is on fire"); // Something's *REALLY* wrong
@nabijaczleweli
nabijaczleweli / a.hpp
Last active September 16, 2015 23:49
Directive store
// The MIT License (MIT)
// Copyright (c) 2015 nabijaczleweli
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions: