Skip to content

Instantly share code, notes, and snippets.

View excavador's full-sized avatar

Oleg Tsarev excavador

View GitHub Profile
/*
* This file is part of Z-Reader (c) 2013
*
* Z-Reader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Z-Reader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
/*
* This file is part of Z-Reader (c) 2013
*
* Z-Reader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Z-Reader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
/*
* This file is part of Z-Reader (c) 2013
*
* Z-Reader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Z-Reader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
/*
* This file is part of Z-Reader (c) 2013
*
* Z-Reader is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Z-Reader is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
private def exchange(request : Req)(code : String) : Option[Token] = {
val client = new DefaultHttpClient
val request = new HttpPost(entryURL)
val params = List(
("code", code),
("client_id", settings.clientId),
("client_secret", settings.clientSecret),
("redirectUri", settings.redirectUri),
("grantType", "authorization_code")).
map(p => new BasicNameValuePair(p._1, p._2))
case class Callback(settings: Settings) extends RestHelper {
private def exchange(request : Req)(code : String): Option[Token] = {
val client = new DefaultHttpClient
val request = new HttpPost(entryURL)
val params = List(
("code", code),
("client_id", settings.clientId),
("client_secret", settings.clientSecret),
("redirectUri", settings.redirectUri),
("grantType", "authorization_code")).
/**
* Token for access to Google API
* @param accessToken the token that can be sent to a Google API
* @param refreshToken a token that may be used to obtain a new access token. Refresh tokens are valid until the user revokes access. This field is only present if access_type=offline is included in the authorization code request.
* @param expiresIn the remaining lifetime on the access token
* @param tokenType indicates the type of token returned. At this time, this field will always have the value Bearer
*/
case class Token(accessToken : String,
refreshToken : Option[String] = None,
expiresIn : Integer,
abstract class Response
case class Token() extends Response
case class Problem() extends Response
case class Connection() extends Problem
case class InvalidResponse() extends Problem
#include <boost/utility.hpp>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
class Repeater : boost::noncopyable
{
public:
typedef bool(*Action)();
Repeater(boost::asio::io_service& io,
Action action,
#include <fstream>
#include <iostream>
#include <unordered_set>
#include <boost/format.hpp>
typedef std::unordered_set<uint64_t> Set;
void load(Set& data, const std::string& filename)
{
uint64_t current;