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
# 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 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 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 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 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 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
use std::fmt::Debug; | |
pub trait State: Debug { | |
fn execute(&self) -> Transition; | |
} | |
pub trait TransitionTo<S: State + 'static>: State { | |
fn transition_to(&self, to: &'static S) -> Transition { | |
Transition { to } | |
} |
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
// Tokio-based server | |
use std::io; | |
use std::iter::FromIterator; | |
use std::time::Duration; | |
use tokio::io::{AsyncReadExt, AsyncWriteExt}; | |
use tokio::net::{TcpListener, TcpStream}; | |
// Listening server. |
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
#!/bin/bash | |
# Run AppImage container | |
set -e | |
function _mount { | |
local target | |
target="$(mktemp --tmpdir --directory appimage.XXXXXXXXXX)" | |
/bin/mount --types squashfs -o offset="${2:-0}" --read-only -- "${1}" "${target}" | |
echo "${target}" | |
} |
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
// Example of NFC using Windows Proximity APIs | |
// Tested using Sony RC-S380 (make sure you enable NFP in the driver). | |
use winrt::*; // import various helper types | |
use winrt::windows::foundation; | |
use winrt::windows::networking::proximity; | |
use std::{thread, time}; | |
const URL: &str = "https://dcoles.net"; |
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
""" | |
Example of NFC using Windows Proximity class. | |
Tested using Sony RC-S380 (make sure you enable NFP in the driver). | |
Requires Windows 10 and Python 3.7+ (for WinRT/Python). | |
""" | |
import sys | |
import time |
NewerOlder