Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am wilhelmtell on github.
  • I am wilhelmtell (https://keybase.io/wilhelmtell) on keybase.
  • I have a public key whose fingerprint is 8702 6ACC 79E5 235F 11A3 837D D428 19EA D130 1F36

To claim this, I am signing this object:

View functional_verbosity.cc
#include <cmath>
int main() {
auto const cos = [](auto const& exp) { return [&]() { return std::cos(exp()); }; };
auto const sin = [](auto const& exp) { return [&]() { return std::sin(exp()); }; };
auto const term = [](auto const& x) { return [&]() { return x; }; };
auto const eval = [](auto const& exp) { return exp(); };
std::cout << eval(cos(sin(term(0.5 * M_PI)))) << '\n';
}
@wilhelmtell
wilhelmtell / exclusive.cc
Last active Aug 29, 2015
Extract responsibility for exclusivity in a RAII class?
View exclusive.cc
#include <utility>
#include <iostream>
struct exclusive {
exclusive() : o{true} { std::cout << this << " exclusive init\n"; }
~exclusive() {
if(owning())
std::cout << this << " exclusive cleanup\n";
else
std::cout << this << " exclusive no cleanup\n";
View gist:3924563
I don't find this "cache end()" guideline of LLVM right: http://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop It's a case of premature optimization, and it actually leaves room for error because the new identifier is a non-const lvalue.
View gist:845950
#include <iterator>
#include <iostream>
#include <vector>
#include <algorithm>
template<class I, class S>
struct n_iterator : public std::iterator_traits<I> {
n_iterator();
n_iterator(I iter, S n);
View gist:656567
try {
std::vector<int> v;
// gtfo of try, so we only catch the ctor's error
} catch (const std::bad_alloc& e) {
// ...
}
// damn it, so now v's out of scope!
View gist:624096
#!/bin/bash
# git read eval print loop
P='git> ';
echo -e -n "$P";
while read L; do
if [ "$L" = "quit" -o "$L" = q ]; then
break;
fi;
git "$L";
View gist:490687
namespace System {
class Exception<T> : Exception {
public Exception() { }
public Exception(string message) : base(message) { }
public Exception(string message, Exception inner)
: base(message, inner){ }
}
}
namespace App {
View gist:404495
from_dot()
{
[ $# -gt 0 ] && local FROM="$@";
sed '/[{}]/d; s/^\s*\|\s*\[[^]]*\]\s*\|\s*;\s*$//g; s/\s/_/g; s/\s*->\s*/ /' $FROM;
}
from_dot graph.dot |tsort #|tac
View gist:390388
#include <iostream>
using namespace std;
union ufloat {
float f;
char b[sizeof(float)];
};
int main(int argc, char* argv[])
You can’t perform that action at this time.