Skip to content

Instantly share code, notes, and snippets.

View Tosainu's full-sized avatar
🌸
ヾ( ╹◡╹ 🌸 )ノ"

Kenta Sato Tosainu

🌸
ヾ( ╹◡╹ 🌸 )ノ"
View GitHub Profile
@Tosainu
Tosainu / nyan.cc
Last active August 19, 2016 18:11
oauth/access_token response parser
#include <iostream>
#include <unordered_map>
#include <boost/fusion/include/std_pair.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_grammar.hpp>
namespace qi = boost::spirit::qi;
template <class String, class Iterator = typename String::const_iterator>
struct query_string : qi::grammar<Iterator, std::unordered_map<String, String>()> {
@Tosainu
Tosainu / Makefile
Last active December 22, 2015 16:54
# nyan!
TARGET = out
SRC = http_client.cc
# compiler configs
CFLAGS = /nologo /c /EHsc /GL /GS /Gy /MD /MP /O2 /W3 /Zi /sdl /Fd:$(TARGET).pdb
INCPATH = /I"$(BOOST_INCLUDEDIR)" /I"$(OPENSSL_INCLUDEDIR)"
DEFINES = /D_WIN32_WINNT=0x0601
@Tosainu
Tosainu / nyan.cc
Last active December 23, 2015 11:29
nyan
#include <iostream>
#include <chrono>
int main(int argc, char const* argv[]) {
const auto before = std::chrono::system_clock::now();
for (long long int i = 0; i < 100000000; i++) {
i + 1;
}
#include <iostream>
#include <unordered_map>
extern "C" {
#include <arpa/inet.h>
#include <sys/socket.h>
#include <ifaddrs.h>
}
std::unordered_map<std::string, std::string> get_if_list() {
source 'https://rubygems.org'
gem 'slack-ruby-client'
gem 'eventmachine'
gem 'faye-websocket'
FROM ruby:2.6-alpine
ADD bot.rb config.rb Gemfile /usr/src/app/
WORKDIR /usr/src/app/
RUN \
apk upgrade --no-cache && \
apk add --no-cache --virtual gem-dependencies \
libgcc \
libstdc++ \
@Tosainu
Tosainu / q0000.hs
Last active October 16, 2017 13:58
AOJ
{-# OPTIONS_GHC -Wall -Werror #-}
import Control.Applicative
qq :: Int -> Int -> String
qq x y = show x ++ "x" ++ show y ++ "=" ++ show (x * y)
main :: IO ()
main = mapM_ putStrLn $ qq <$> [1..9] <*> [1..9]
#!/usr/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 DEST"
exit -1
fi
if [ ! -d $1 ]; then
echo "error: no such directory $1"
exit -1
@Tosainu
Tosainu / Makefile
Last active June 14, 2016 13:13
seccamp'16 選択問題4
all: parser
parser: ./rhp.cc
clang++ -std=c++14 -Wall -Wextra -pedantic -O2 -march=native $< -o $@
debug: parser_debug
parser_debug: ./rhp.cc
clang++ -std=c++14 -Wall -Wextra -pedantic -g -O0 $< -o $@
#include <cstdint>
template <class Address, class Register, Address address>
struct reg_t {
static inline void write(Register value) {
*reinterpret_cast<volatile Address*>(address) = value;
}
static inline Register read() {
return *reinterpret_cast<volatile Address*>(address);