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
import { | |
useMantineTheme, | |
Grid, | |
Card, | |
Image, | |
Group, | |
Text, | |
Button, | |
Badge, | |
} from "@mantine/core"; |
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
export default function BlogForm() { | |
async function handleSubmit(event) { | |
event.preventDefault(); | |
const form = event.target; | |
const data = new FormData(form); | |
const title = data.get("title"); | |
const content = data.get("content"); | |
const blog = { title, content }; | |
const res = await fetch("/api/blog", { |
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
import { auth, googleProvider } from "./firebase"; | |
import { createContext } from "react"; | |
const AuthContext = createContext(); | |
const AuthProvider = () => { | |
// States we can use to check if user is logged in or not or if there is an error or if the user is loading | |
const [user, setUser] = useState(null); | |
const [loading, setLoading] = useState(true); |
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 rand::Rng; | |
use std::io; | |
fn main() { | |
let secret_number: i32 = rand::thread_rng().gen_range(1..=3); | |
println!("The secret number is: {}", secret_number); | |
let computer_choice: &str = if secret_number == 1 { | |
"rock" | |
} else if secret_number == 2 { |
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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"github.com/bwmarrin/discordgo" | |
) |
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
func Respond(s *discordgo.Session, i *discordgo.InteractionCreate, content string) { | |
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ | |
Type: discordgo.InteractionResponseChannelMessageWithSource, | |
Data: &discordgo.InteractionResponseData{ | |
Content: content, | |
Flags: 1 << 6, | |
}, | |
}) | |
if err != nil { | |
log.Printf("Error sending message to discord: %v", err) |
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
C:\Code\rust-cli>cargo check | |
Checking rust-cli v0.1.0 (C:\Code\rust-cli) | |
error[E0277]: `Languages` doesn't implement `std::fmt::Display` | |
--> src\main.rs:30:16 | |
| | |
30 | .items(&languages) | |
| ----- ^^^^^^^^^^ `Languages` cannot be formatted with the default formatter | |
| | | |
| required by a bound introduced by this call | |
| |
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 dialoguer::{theme::ColorfulTheme, Select}; | |
use strum::{Display, EnumIter, IntoEnumIterator}; | |
#[derive(Debug, EnumIter, Display, Clone, Copy)] | |
enum Languages { | |
TypeScript, | |
JavaScript, | |
} | |
#[derive(Debug, EnumIter, Display, Clone, Copy)] |
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
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) | |
--> src\prompts\packages_prompt.rs:21:42 | |
| | |
13 | / pub fn ask_packages() -> Vec<Packages> { | |
14 | | let package_list: Vec<_> = Packages::iter().collect(); | |
15 | | | |
16 | | let selection = MultiSelect::with_theme(&ColorfulTheme::default()) | |
... | | |
21 | | .interact_on_opt(&Term::stdout())?; | |
| | ^ cannot use the `?` operator in a function that returns `Vec<packages_prompt::Packages>` |
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 get_name() -> String { | |
let name = dialoguer::Input::new() | |
.with_prompt("What is your name?") | |
.interact() | |
.expect("Name failed"); | |
name | |
} |
OlderNewer