This file contains hidden or 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
| #!/usr/bin/env python | |
| # POSIX Alarm Timer example using Python ctypes | |
| # | |
| # Author: David Coles <coles.david@gmail.com> | |
| # Date: 2012-03-19 | |
| # | |
| # To the extent possible under law, the author(s) have dedicated all copyright | |
| # and related and neighboring rights to this software to the public domain | |
| # worldwide. This software is distributed without any warranty. |
This file contains hidden or 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
| /** | |
| * C99 features that don't work in C++ | |
| * | |
| * Written in 2011 by David Coles https://dcoles.net/ | |
| * | |
| * To the extent possible under law, the author(s) have dedicated all copyright and related and | |
| * neighboring rights to this software to the public domain worldwide. | |
| * This software is distributed without any warranty. | |
| */ |
This file contains hidden or 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
| //! Furi Event Flag. | |
| use core::cell::UnsafeCell; | |
| use core::ops::Deref; | |
| use core::ptr::NonNull; | |
| use crate::furi::time::FuriDuration; | |
| use crate::furi::Error; | |
| use flipperzero_sys as sys; | |
| use flipperzero_sys::furi::{Handle, Status}; |
This file contains hidden or 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
| # SPA bindings | |
| import os | |
| import functools | |
| from spa._cffi import ffi | |
| from spa.pod import PodObject | |
| from spa.constants import SPA_TYPE_COMMAND__NODE | |
This file contains hidden or 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
| #![no_main] | |
| #![no_std] | |
| // Required for panic handler | |
| extern crate flipperzero_rt; | |
| use core::{ffi::{c_void, CStr}, ops::{Deref, DerefMut}, ptr}; | |
| use flipperzero::{furi::{self, stream_buffer::FuriStreamBuffer, thread::{self, ThreadId}, time::Duration}, info, log, println}; | |
| use flipperzero_rt::{entry, manifest}; |
This file contains hidden or 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
| //! A simple Type-Length-Value format inspired by `postcard-rpc` | |
| //! | |
| //! Author: David Coles <https://github.com/dcoles/> | |
| //! SPDX-License-Identifier: MIT | |
| use std::io::{Read, Write, Cursor}; | |
| use std::time; | |
| use postcard::experimental::schema::Schema; | |
| use postcard_rpc::hash::fnv1a64::hash_ty_path; | |
| use serde::{Deserialize, Serialize}; |
This file contains hidden or 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 ctypes | |
| import sys | |
| import os | |
| import errno | |
| FUNC = ctypes.CFUNCTYPE(None) | |
| PROT_NONE = 0 | |
| PROT_READ = 1 | |
| PROT_WRITE = 2 |
This file contains hidden or 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
| """ | |
| By only adding + - * into the string 452874 (in that order), | |
| how many way can you get to -18? | |
| """ | |
| N = "452874" | |
| M = -18 | |
| OPERATIONS = [None, '+', '-', '*'] |
This file contains hidden or 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 main() { | |
| let input = read_input_from_file("day01/input.txt").unwrap(); | |
| // Part 1 | |
| let mut count = 0; | |
| let mut last = -1; | |
| for &n in &input { | |
| if n > last { | |
| count += 1; | |
| } |
This file contains hidden or 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
| # Print the number of bytes unread in a fifo. | |
| # David Coles <coles.david@gmail.com> | |
| import argparse | |
| import ctypes | |
| import fcntl | |
| import os | |
| import sys | |
| import termios |
NewerOlder