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
| use libp2p::{ | |
| core::transport::upgrade, | |
| futures::StreamExt, | |
| identity, mplex, noise, | |
| ping::{Ping, PingConfig, PingEvent}, | |
| rendezvous, | |
| swarm::{AddressScore, SwarmBuilder, SwarmEvent}, | |
| Multiaddr, NetworkBehaviour, PeerId, Swarm, Transport, | |
| }; |
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
| // (condp apply [2 3] | |
| // = "eq" | |
| // < "lt" | |
| // > "gt") | |
| // ;;=> "lt" | |
| macro_rules! condp_apply { | |
| ( $input:tt, {$($func:tt: $r:tt),*} ) => { | |
| { | |
| let mut result: &str = "other"; |
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
| (ns queens | |
| (:require [interfaces :refer [enumerate-interval]])) | |
| ;; Solution for Eight Queens Problem from SICP 2.42 | |
| (def empty-board [[[]]]) | |
| (def board-size 8) | |
| (defn safe? [k positions] |
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
| (def m {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9 :j 534}) | |
| ;; Split to chunks by count | |
| (defn bucketize [rows] | |
| (reduce | |
| (fn [acc [k v]] | |
| (if (< (count (last acc)) 3) | |
| (assoc-in acc [(- (count acc) 1)] (conj (last acc) v)) | |
| (conj acc [v]))) | |
| [[]] rows)) |
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 python3 | |
| import enum | |
| import sys | |
| import time | |
| from typing import Tuple | |
| from ev3dev2.motor import OUTPUT_A, OUTPUT_D, LargeMotor, MediumMotor, SpeedPercent | |
| from ev3dev2.sensor import INPUT_1 | |
| from ev3dev2.sensor.lego import ColorSensor |
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
| let image_wrapper = ImageWrapper::new(); | |
| // Add newly generated image. | |
| image_wrapper.set_image(image_gtk); | |
| // Remove existing image from the wrapper struct. | |
| match image_wrapper.get_image() { | |
| Ok(image) => box_vert.remove(&image), | |
| Err(e) => println!("{}", e), | |
| } |
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
| type ImageRef = Rc<RefCell<Option<gtk::Image>>>; | |
| #[derive(Clone)] | |
| struct ImageWrapper { | |
| internal_value: ImageRef | |
| } | |
| impl ImageWrapper { | |
| fn new() -> ImageWrapper { | |
| ImageWrapper { internal_value: Rc::new(RefCell::new(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
| // Instantiate Option which will help us mutate the image | |
| // from within the closure. | |
| let image_wrapper: Rc<RefCell<Option<gtk::Image>>> = Rc::new(RefCell::new(None)); | |
| // (...) | |
| // Bind action to the generate button | |
| generate_button.connect_clicked(clone!( | |
| box_vert, image_wrapper, spiral, adj_x, radio_primes => move |_| { |
NewerOlder