Skip to content

Instantly share code, notes, and snippets.

View ognis1205's full-sized avatar
πŸˆβ€β¬›

Shingo OKAWA ognis1205

πŸˆβ€β¬›
View GitHub Profile
<!-- reset.css ress -->
<link
rel="stylesheet"
href="https://unpkg.com/ress/dist/ress.min.css"
/>
@ognis1205
ognis1205 / base64.py
Last active September 2, 2022 12:19
Simple Implementation of Base64 encoding/decoding in Python.
import sys
from traceback import format_exc
NUM2CHAR = (
r'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
r'abcdefghijklmnopqrstuvwxyz'
r'0123456789+/'
)
@ognis1205
ognis1205 / wolfram.py
Created December 1, 2022 21:01
Wolfram's 2-state-3-symbol Turing Machine in Python
from time import sleep
delta = {
1: {
0: ( 1, 1, 2),
1: ( 2, -1, 1),
2: ( 1, -1, 1)
},
2: {
0: ( 2, -1, 1),
#include <stdio.h>
void a_function() {
printf("This is a_function!\n");
}
void a_function();
int main() {
a_function();
}
[package]
name = "my-first-pyo3"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "my_first_pyo3"
crate-type = ["cdylib"]
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"
[project]
name = "my-first-pyo3"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
use pyo3::prelude::*;
/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
/// A Python module implemented in Rust.
#[pymodule]
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
use pyo3::prelude::*;
/// Formats the sum of two numbers as string.
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
let x: &'static str = "Hello, world.";