Skip to content

Instantly share code, notes, and snippets.

View alibitek's full-sized avatar
🌱
Growing

Alex Bitek alibitek

🌱
Growing
View GitHub Profile
@alibitek
alibitek / gist:3343393
Created August 13, 2012 19:14
C++ Lambda Expressions
// 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;
@alibitek
alibitek / asio_range_util.hpp
Created December 5, 2012 15:40 — forked from kikairoya/asio_range_util.hpp
asio http client without istream
#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) {
#include <iostream>
#include <thread>
#include <future>
#include <chrono>
#include <functional>
#include <deque>
struct task_queue {
task_queue() = default;
task_queue(const task_queue &) = delete;
void http_session::handle_write(const error_code& ec,std::size_t sz)
{
if(!ec)
{
if(keep_alive_)
{
handle_handshake(error_code());
}
else
{
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());
@alibitek
alibitek / boost.txt
Created April 16, 2013 17:52
Boost CMake configuration.
# 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}")
@alibitek
alibitek / reinstall_grub2_bios.txt
Last active December 23, 2015 20:29
Easiest way to reinstall Grub 2 on BIOS system
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
@alibitek
alibitek / dd_progress
Created November 27, 2013 08:56
Make dd print (output) progress
# 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}')
#!/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)"
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;