Skip to content

Instantly share code, notes, and snippets.

View recuraki's full-sized avatar

Akira KANAI recuraki

View GitHub Profile
@recuraki
recuraki / colored_arupaka.py
Created June 22, 2021 15:39
アルパカ塗り
from PIL import Image, ImageDraw, ImageChops, ImageEnhance
img = Image.open("animal_arupaka.png")
dat = img.split()
r,b,g,a = img.split()
basecolor = (212, 195, 188) #毛の色
cangap = 18
# 毛を推察する。+-gapは許容
r = r.point(lambda x: 1 if basecolor[0] - cangap <= x <= basecolor[0] + cangap else 0, mode="1")
@recuraki
recuraki / boost_split.cpp
Last active June 22, 2021 04:46
boostでのsplit
#include <iostream>
#include <string>
#include <vector>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/range/algorithm/for_each.hpp>
using namespace std;
void test(string s){
vector<std::string> result;
cout << "Parse STR: \"" << s << "\"\n";
@recuraki
recuraki / pointer.c
Last active May 27, 2021 13:35
pointer
#include <stdio.h>
long func(int x) { return x + 1; }
long func2(int x) { return x + 2; }
int main() {
// 64bitの場合、関数は64bitなのでlongにする
long a, b;
long (*c)(long); // 正しい関数ポインタ
// まず、定義したfuncのアドレスを調べる
printf("func value is %lx\n", func);
printf("func2 value is %lx\n", func2);
@recuraki
recuraki / fraction.cpp
Created May 10, 2021 13:50
小数の比較
#include <bits/stdc++.h>
using namespace std;
void f(string A, string X, string Y){
cout << "a, x, y = " << A << ", " << X << ", " << Y << "\n";
double dA=stod(A), dX=stod(X), dY=stod(Y);
long double ldA=stold(A), ldX=stold(X), ldY=stold(Y);
long lA=stol(A), lX=stol(X), lY=stol(Y);
/* 入力をdoubleで比較 */
if ((dA/dX) == (dA/dY)) cout << "double : a/x == a/y" << "\n";
@recuraki
recuraki / fraction.py
Created May 10, 2021 13:49
小数の比較.py
# a/b == Fraction(a,b) 有理数計算クラス
from fractions import Fraction
from decimal import Decimal
def f(a, x, y):
print("a, x, y,", a, ",", x, ",", y)
a = int(a)
x = int(x) # 1e16 + 1
y = int(y) # 1e16 + 2
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
using namespace std;
using namespace atcoder;
const int numNode = 2*100000;
const int numColor = 4 * 100000;
const int numGraph = numNode + numColor + 100;
const int snode = numGraph - 3;
const int tnode = numGraph - 2;
@recuraki
recuraki / iv18.cpp
Created March 15, 2021 14:57
IV18を制御するAVR I2Cスレーブコード
// 本コードの
// I2C部分は中尾 司様の以下コードを参考にしています
// http://www.eleki-jack.com/mycom2/2007/12/avri2c8twii2c_4.html#more
// 07/11/15 www.wsnak.com T.Nakao
// また、nora66さんのコメントを参考にしています。
// http://nora66.com/avr/prog2.html
// タイマーコード部分はsim00様の以下のコードを参考にしています
// http://blog.goo.ne.jp/sim00/e/1ab8d1564106581d1168edc059042c30
@recuraki
recuraki / HP5082.c
Last active March 13, 2021 15:22
HP5082を制御します。
// 本コードの
// I2C部分は中尾 司様の以下コードを参考にしています
// http://www.eleki-jack.com/mycom2/2007/12/avri2c8twii2c_4.html#more
// 07/11/15 www.wsnak.com T.Nakao
// また、nora66さんのコメントを参考にしています。
// http://nora66.com/avr/prog2.html
// タイマーコード部分はsim00様の以下のコードを参考にしています
// http://blog.goo.ne.jp/sim00/e/1ab8d1564106581d1168edc059042c30
"""
これなに?
Slackのあなたの書き込みを消します。
クエリの調べ方
https://api.slack.com/methods/pins.list
とか見て、適当にTester画面からクエリ送ります。
URLでるので、良しなに書き換えましょう
準備
@recuraki
recuraki / 上手くいかないコード.py
Created February 21, 2021 04:37
ハッシュ衝突をさせたい
"""
static Py_ssize_t
find_empty_slot(PyDictKeysObject *keys, Py_hash_t hash)
{
assert(keys != NULL);
const size_t mask = DK_MASK(keys);
size_t i = hash & mask;
Py_ssize_t ix = dictkeys_get_index(keys, i);