Skip to content

Instantly share code, notes, and snippets.

View ryohji's full-sized avatar

Ryohji Ikebe ryohji

  • Tokyo, Japan
View GitHub Profile
@ryohji
ryohji / not.md
Last active November 7, 2020 06:54
not operator in C

C 言語の not 演算子には2種類ある。 ~!。論理学では ~ を否定で使うことが多いけれど C 言語での論理否定は !~ はビットごとの否定。

ビットごとの否定

// bitwise-not.c
#include <stdbool.h>

int main() { return ~false; }
@ryohji
ryohji / roff.c
Last active February 10, 2021 17:14
umoria roff
static vtype roffbuf; // Line buffer.
static char *roffp = roffbuf; // Pointer into line buffer.
static int roffpline = 0; // Place to print line now being loaded.
static uint8_t count_previous_non_blank_chars(const char *from);
// Print out strings, filling up lines as we go.
static void roff(const char *p) {
uint8_t count;
loop:
@ryohji
ryohji / cleanup_list.py
Last active August 9, 2021 06:50
リストから不要な要素を取りのぞく方法
import unittest
def cleanup_list(list):
i = 0
while i < len(list): # pop のたびに list 長が変わる
elem = list[i]
if not elem.alive:
list.pop(i)
else:
@ryohji
ryohji / update_all_elements_in_vector.cc
Created January 21, 2022 16:33
Use transform(map) function to modify the elements in a container. [C++]
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
int main() {
auto v = std::vector<int> {1, 2, 3};
// Use transform to update all elements in the vector.
std::transform(std::cbegin(v), std::cend(v), std::begin(v),
1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月
1 32 60 91 121 152 182 213 244 274 305 335
2 33 61 92 122 153 183 214 245 275 306 336
3 34 62 93 123 154 184 215 246 276 307 337
4 35 63 94 124 155 185 216 247 277 308 338
5 36 64 95 125 156 186 217 248 278 309 339
6 37 65 96 126 157 187 218 249 279 310 340
7 38 66 97 127 158 188 219 250 280 311 341
8 39 67 98 128 159 189 220 251 281 312 342