Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Rapptz / get.cpp
Last active August 29, 2015 14:16
#include <requests/request.hpp>
#include <iostream>
int main() {
auto r = requests::get("http://www.example.com");
std::cout << "Number of headers: " << r.headers.size() << '\n';
for(auto&& i : r.headers) {
std::cout << i .first<< ": " << i.second << '\n';
}
std::cout << r.status_code << '\n';
#include <requests/request.hpp>
#include <iostream>
int main() {
auto r = requests::get("http://www.example.com");
std::cout << r.status_code << '\n';
std::cout << r.text << '\n';
std::cout << r.url << '\n';
}
@Rapptz
Rapptz / client.cpp
Last active August 29, 2015 14:15
Sockets.
#include <net/socket.hpp>
#include <iostream>
int main() {
net::socket client(net::socket::ipv4, net::socket::stream);
client.connect("127.0.0.1", 3667);
std::cout << client.receive(16);
}
@Rapptz
Rapptz / tiebreaker.md
Created December 14, 2014 19:19
Median-Buchholz

How Median-Buchholz tie breaker works.

Assumptions:

  1. We are talking about 2 different players, P1 and P2.
  2. They each played 6 rounds.
  3. They each won 4 of them and lost two of them (i.e. they're tied).

After all 6 rounds, the opponents for P1 ended up with the following track record:

import sys
print(sys.argv)
@Rapptz
Rapptz / sen.py
Last active August 29, 2015 14:09
A meta build system for ninja. Called sen.py based on senpai/sempai.
#!/usr/bin/env python
"""Python module that generates .ninja files.
Some of the stuff here was borrowed from the main ninja project.
However this module aims to extend the bare-bones provided with a rich
python API.
Note: This file is meant to be a single file for easy inclusion for existing
build systems. Hence this file will be rather big.
@Rapptz
Rapptz / legal.md
Last active August 29, 2015 14:08
Smash 4 Wii U Legal Stages
@Rapptz
Rapptz / signals.cpp
Created August 17, 2014 10:41
Signal and Slots C++11
// C++11 signal/slots
#include <type_traits>
#include <functional>
#include <map>
#include <limits>
namespace signals {
struct connection_key {
private:
connection_key() = default;
local tuple = require("tuple")
function test(x, y, z)
print(x, y, z)
end
function get()
return 10, 11
end
@Rapptz
Rapptz / xclip.cpp
Last active February 21, 2024 03:50
Windows port of xclip
// The MIT License (MIT)
// Copyright (c) 2014 Rapptz
// 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: