Skip to content

Instantly share code, notes, and snippets.

View xeno14's full-sized avatar

Ryo Murakami xeno14

View GitHub Profile
@xeno14
xeno14 / gist:6188291aedcb2cd2dc15
Created June 15, 2015 14:30
Compile-time calculation of Pi
#include <cstdio>
#include <ratio>
template <typename R, intmax_t N>
struct ratio_pow {
using prev = typename ratio_pow<R, N-1>::value;
using value = std::ratio<R::num * prev::num, R::den * prev::den>;
};
template <typename R>
@xeno14
xeno14 / .nvimrc
Last active August 29, 2015 14:27
minimized nvimrc with lightline
"----------------------------------------------------
" appearance
"----------------------------------------------------
"
syntax on
set laststatus=2
set t_Co=256
" colorscheme desert
@xeno14
xeno14 / ipython-notebook.service
Last active November 11, 2015 13:05 — forked from amitsaha/ipython-notebook.service
Run IPython notebook under systemd
# README:
# Copy this file to /usr/lib/systemd/system/
# sudo systemctl daemon-reload
# systemctl enable ipython-notebook
# systemctl start ipython-notebook
# The WorkingDirectory and ipython-dir must exist
# If you don't want anything fancy, go to http://127.0.0.1:8888 to see your notebook
# wheneber you want it
[Unit]
@xeno14
xeno14 / mix.py
Last active December 31, 2015 10:14
#!/usr/bin/env python
# -*- coding: utf-8 -*-
fa = open("a.txt", "r")
fb = open("b.txt", "r")
for a, b in zip(fa, fb):
print a.rstrip()
print b.rstrip()
fa.close()
fb.close()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@xeno14
xeno14 / gist:9b16acfe5f3cf8c3ef706249bbda1a41
Last active April 2, 2017 09:48
DMM英会話のレッスン予約完了メールをGmailからパースしてGoogleカレンダーに予約するGoogle App Script
// 本体
function DMMCalenderFromGmail() {
// prefixとsuffixに挟まれた文字列の取得
function findLine(body, prefix, suffix) {
var istart, iend;
istart = body.indexOf(prefix) + prefix.length;
iend = istart + body.slice(istart).indexOf(suffix);
return body.slice(istart, iend);
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!
#include-once
#include
#cloud-config
#cloud-boothook
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
@xeno14
xeno14 / a.py
Created March 11, 2018 01:00
Bind another IP address in requests
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
class SourceAddressAdapter(HTTPAdapter):
def __init__(self, source_address, **kwargs):
self.source_address = source_address
super(SourceAddressAdapter, self).__init__(**kwargs)