Skip to content

Instantly share code, notes, and snippets.

@WhiteGrouse
WhiteGrouse / main.c
Created December 12, 2025 10:21
ESP32-S3のULP RISC-VでGPIOのホールドを設定、解除する方法
#include <esp_log.h>
#include <esp_sleep.h>
#include <ulp_riscv.h>
#include <driver/rtc_io.h>
#include <driver/gpio.h>
#include <soc/rtc_periph.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
use std::time::Duration;
use std::sync::atomic::{AtomicBool, Ordering};
use async_std::io::{self, ErrorKind};
use async_std::net::{ToSocketAddrs, UdpSocket};
use async_std::sync::{Arc, Weak};
use async_std::channel::{bounded, Sender, Receiver};
use async_std::task::{self, JoinHandle};
struct Listener {
recv_task: Option<JoinHandle<()>>,
@WhiteGrouse
WhiteGrouse / permutation.c
Created December 24, 2021 08:23
文字の入れ替えで順列出力
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int count = 0;
void print(char* str) {
count++;
printf("%s\n", str);
}
@WhiteGrouse
WhiteGrouse / NPlusOneCoordProblem.cs
Created May 14, 2021 05:05
原点からの距離が一定で、どの2点をとっても距離が同じであるような座標をN次元空間にN+1個配置する方法
using System;
using System.Linq;
namespace NPlusOneCoordProblem
{
class Program
{
static void Main(string[] args)
{
double R = 2;
using System;
namespace OptionExample
{
public class Option<T>
{
private readonly bool _hasValue;
private readonly T _value;
public bool HasValue => _hasValue;
@WhiteGrouse
WhiteGrouse / discord.php
Created December 17, 2020 15:59
botが参加しているサーバと、そのサーバのチャンネルの一覧を表示するサンプル
<?php
require __DIR__ . '/../vendor/autoload.php';
use Discord\Discord;
$discord = new Discord([
'token' => '',
'logging' => false
]);
@WhiteGrouse
WhiteGrouse / main.rs
Created December 16, 2020 03:48
Collatz Problem
extern crate num_bigint;
extern crate num_traits;
mod utils;
use num_bigint::BigUint;
use utils::input_num;
fn main() {
let mut x = trim(input_num(10));
#[macro_use]
extern crate lazy_static;
mod console_io;
use console_io::*;
use std::fmt;
use std::collections::HashMap;
use std::ops::{Add, Shl, Shr, Mul};
@WhiteGrouse
WhiteGrouse / connection.rs
Last active September 21, 2020 17:44
切断通知付き、仮想コネクション
use async_std::prelude::FutureExt;
use async_std::net::SocketAddr;
use async_std::sync::{channel, Sender, Receiver};
use async_std::task;
const QUEUE_SIZE: usize = 128;
pub struct Communicator<T> {
tx_packet: Sender<T>,
rx_packet: Receiver<T>,
use async_std::sync::{Arc, Weak, Mutex};
use async_std::task::{self, JoinHandle};
use futures::future::{abortable, Aborted, AbortHandle};
use std::time::Duration;
fn main() {
task::block_on(async {
let _peer = Peer::new();
});
}