Now revised version is on https://github.com/grafi-tt/melty2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
Serial.begin(9600); | |
analogReference(DEFAULT); | |
} | |
unsigned int co2mon(unsigned long delta) { | |
static const unsigned int SensorIn = A0; | |
static const unsigned int BaseVoltage = 480; | |
static const unsigned int PollInterval = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn byte_to_ascii(byte: u8) -> [u8; 8] { | |
let diag = 0b10000000_01000000_00100000_00010000_00001000_00000100_00000010_00000001u64; | |
let mut byte_ascii = byte as u64 * diag; | |
byte_ascii &= 0x8080808080808080; | |
byte_ascii >>= 7; | |
byte_ascii += 0x3030303030303030; | |
byte_ascii.to_le_bytes() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def show_board(black_board, white_board): | |
black_bytes = black_board.to_bytes(8, byteorder='big') | |
black_array = np.unpackbits(np.frombuffer(black_bytes, dtype=np.uint8)) | |
white_bytes = white_board.to_bytes(8, byteorder='big') | |
white_array = np.unpackbits(np.frombuffer(white_bytes, dtype=np.uint8)) | |
chars = (black_array * (ord(b'b') - ord(b'-')) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 課題3(上級者向け) | |
SUID (Set User ID) ビットを使って、`sudo` コマンドのように root ユーザーとして他のコマンドを実行できるコマンドを作れ。 | |
**注意: 絶対にこのコマンドを実用してはならない。** | |
ヒント: C で書いたプログラムから `execvp` 関数を用いる。スクリプトファイルのすり替えに対処不能というセキュリティ上の問題から、SUID ビットはコンパイルされたプログラムに対してのみ機能する。 | |
<details> | |
<summary>解答</summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__device__ static inline void multfly_device_gen_round_(uint32_t *u, uint32_t *v) { | |
int lane = threadIdx.x & 3; | |
uint32_t mulu = UINT32_C(2718281829); | |
uint32_t mulv = UINT32_C(3141592653); | |
uint32_t incr = UINT32_C(0x33123456); | |
*u += multfly_device_rotl_(incr, lane); | |
*v += *u; | |
*v ^= multfly_device_rotl_(*u, 8); | |
*v *= mulv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// distributed under public domain | |
// work in progress | |
#include <stdint.h> | |
#include <string.h> | |
static int multfly_rotl(uint32_t k, int n) { | |
return (k << n) | (k >> (32 - n)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/chainerx_cc/chainerx/native/reduce.h b/chainerx_cc/chainerx/native/reduce.h | |
index 2b61319de..73db5bad2 100644 | |
--- a/chainerx_cc/chainerx/native/reduce.h | |
+++ b/chainerx_cc/chainerx/native/reduce.h | |
@@ -11,19 +11,83 @@ namespace chainerx { | |
namespace native { | |
namespace reduce_detail { | |
+constexpr int64_t ExpandLen = 8; | |
+constexpr int64_t SerialLen = 16; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modification of Chainer's code | |
# See https://github.com/chainer/chainer/blob/master/LICENSE | |
import numpy | |
import chainer | |
from chainer import backend | |
from chainer.backends import cuda | |
from chainer import configuration | |
from chainer import function_node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chainer | |
import chainer.functions as F | |
import chainer.links as L | |
import numpy as np | |
from chainer import dataset, initializer | |
from chainer.backends import cuda | |
def cipher_ctx(key): | |
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes |
NewerOlder