This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lambda Expressions | |
std::vector<int> v; | |
for (int i = 0; i < 10; i++) | |
{ | |
v.push_back(i); | |
} | |
std::for_each(v.rbegin(), v.rend(), [](int n) { std::cout << n << " "; }); | |
std::cout << std::endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ASIO_RANGE_UTIL_HPP_ | |
#define ASIO_RANGE_UTIL_HPP_ | |
#include <boost/range/iterator_range.hpp> | |
#include <boost/range/algorithm/search.hpp> | |
#include <boost/asio/buffer.hpp> | |
namespace httpc { | |
template <typename T> | |
inline boost::iterator_range<T *> make_iterator_range_from_memory(T *head, size_t size) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <thread> | |
#include <future> | |
#include <chrono> | |
#include <functional> | |
#include <deque> | |
struct task_queue { | |
task_queue() = default; | |
task_queue(const task_queue &) = delete; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void http_session::handle_write(const error_code& ec,std::size_t sz) | |
{ | |
if(!ec) | |
{ | |
if(keep_alive_) | |
{ | |
handle_handshake(error_code()); | |
} | |
else | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::string GZipDecompressString(const std::string& compressedString) | |
{ | |
std::stringstream src(compressedString); | |
if (src.good()) | |
{ | |
boost::iostreams::filtering_istreambuf in; | |
iostreams::gzip_params p; | |
in.push(boost::iostreams::gzip_decompressor()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Boost | |
SET(BOOST_ROOT path/to/where/youve/built/boost/) | |
FIND_PACKAGE(Boost 1.53.0 COMPONENTS filesystem REQUIRED) | |
IF(Boost_FOUND) | |
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIR}) | |
LINK_DIRECTORIES(${Boost_LIBRARY_DIR}) | |
MESSAGE("**Boost information**") | |
MESSAGE("Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Boot to a Live CD/USB | |
2) Mount the root partition | |
sudo mkdir /mnt/sda1 && sudo mount /dev/sda /mnt/sda1 | |
3) Bind the directories that Grub needs access to | |
sudo mount --bind /dev /mnt/sda1/dev && sudo mount --bind /dev/pts /mnt/sda1/dev/pts && sudo mount --bind /proc /mnt/sda1/proc && sudo mount --bind /sys /mnt/sda1/sys | |
4) Jump into the system | |
sudo chroot /mnt/sda1 | |
5) Install Grub | |
grub-install --target=i386-pc --recheck --debug /dev/sda | |
6) Generate configuration files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make dd spit output | |
sudo kill -10 $(pgrep -l '^dd$' | awk -F' ' '{print $1}') | |
sudo watch -n 10 kill -USR1 $(pgrep -l '^dd$' | awk -F' ' '{print $1}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Generates gource video (h.264) out of multiple repositories. | |
# Pass the repositories as command line arguments. | |
# Example: | |
# gource-multiple-repositories /path/to/repo1 /path/to/repo2 | |
i=0 | |
for repo in "$*"; do | |
# 1. Generate a Gource custom log files for each repo. This can be facilitated by the --output-custom-log FILE option of Gource as of 0.29: | |
logfile="$(mktemp /tmp/gource.XXXXXX)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
static class TimeKeeper | |
{ | |
public static readonly Func<DateTime> DefaultTimeKeeper = () => DateTime.UtcNow; | |
private static readonly object LockObject = new object(); | |
private static Func<DateTime> CurrentTimeKeeper = DefaultTimeKeeper; |
OlderNewer